You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2016/03/21 20:40:55 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-6218
Repository: activemq
Updated Branches:
refs/heads/master 30d6ad72f -> ea09159a4
https://issues.apache.org/jira/browse/AMQ-6218
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
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/ea09159a
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/ea09159a
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/ea09159a
Branch: refs/heads/master
Commit: ea09159a4087212964787e7cf68ef30170d115f0
Parents: 30d6ad7
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Mon Mar 21 19:17:26 2016 +0000
Committer: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Committed: Mon Mar 21 19:38:18 2016 +0000
----------------------------------------------------------------------
.../org/apache/activemq/command/ActiveMQTextMessage.java | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/ea09159a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
index 97fc9e4..4618341 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
@@ -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);
}