mirror of
https://github.com/apache/activemq.git
synced 2025-02-22 01:44:53 +00:00
Fixing copy method of ActiveMQTextMessage to prevent a race condition when concurrent store and dispatch is used with Queues We may need explicity synchronization between the text and content fields in the future if other issues pop up (cherry picked from commit ea09159a4087212964787e7cf68ef30170d115f0)
This commit is contained in:
parent
531634fca1
commit
93bc7030e2
@ -55,6 +55,12 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||
}
|
||||
|
||||
private void copy(ActiveMQTextMessage copy) {
|
||||
//AMQ-6218 - Save text before calling super.copy() to prevent a race condition when
|
||||
//concurrent store and dispatch is enabled in KahaDB
|
||||
//The issue is sometimes beforeMarshall() gets called in between the time content and
|
||||
//text are copied to the new object leading to both fields being null when text should
|
||||
//not be null
|
||||
String text = this.text;
|
||||
super.copy(copy);
|
||||
copy.text = text;
|
||||
}
|
||||
@ -79,9 +85,11 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||
@Override
|
||||
public String getText() throws JMSException {
|
||||
ByteSequence content = getContent();
|
||||
String text = this.text;
|
||||
|
||||
if (text == null && content != null) {
|
||||
text = decodeContent(content);
|
||||
this.text = text;
|
||||
setContent(null);
|
||||
setCompressed(false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user