Fix possible GenericMsgTemplate race condition
Fix a potential race condition with GenericMessagingTemplate's inner TemporaryReplyChannel class. Prior to this commit the `hasReceived` member variable was read after calling `replyLatch.countDown()`. Issue: SPR-11206
This commit is contained in:
parent
f57c4a09ee
commit
a1529d498e
|
|
@ -119,7 +119,6 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected final Message<?> doReceive(MessageChannel channel) {
|
||||
|
||||
|
|
@ -230,13 +229,14 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
|
|||
public boolean send(Message<?> message, long timeout) {
|
||||
|
||||
this.replyMessage = message;
|
||||
boolean alreadyReceivedReply = this.hasReceived;
|
||||
this.replyLatch.countDown();
|
||||
|
||||
String errorDescription = null;
|
||||
if (this.hasTimedOut) {
|
||||
errorDescription = "Reply message received but the receiving thread has exited due to a timeout";
|
||||
}
|
||||
else if (this.hasReceived) {
|
||||
else if (alreadyReceivedReply) {
|
||||
errorDescription = "Reply message received but the receiving thread has already received a reply";
|
||||
}
|
||||
else if (this.hasSendFailed) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue