Skip to content

Commit 1b56b84

Browse files
garyrussellartembilan
authored andcommitted
GH-1293: Fix regression
- NPE in deprecated `CorrelationData.getReturnedMessage()`.
1 parent bdbb667 commit 1b56b84

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CorrelationData.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ public SettableListenableFuture<Confirm> getFuture() {
106106
@Deprecated
107107
@Nullable
108108
public Message getReturnedMessage() {
109-
return this.returnedMessage.getMessage();
109+
if (this.returnedMessage == null) {
110+
return null;
111+
}
112+
else {
113+
return this.returnedMessage.getMessage();
114+
}
110115
}
111116

112117
/**

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2020 the original author or authors.
2+
* Copyright 2019-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,6 +64,13 @@
6464
@RabbitAvailable
6565
public class PublisherCallbackChannelTests {
6666

67+
@SuppressWarnings("deprecation")
68+
@Test
69+
void correlationData() {
70+
CorrelationData cd = new CorrelationData();
71+
assertThat(cd.getReturnedMessage()).isNull();
72+
}
73+
6774
@Test
6875
void shutdownWhileCreate() throws IOException, TimeoutException {
6976
Channel delegate = mock(Channel.class);

0 commit comments

Comments
 (0)