From 8136e67b408a3d756241ebdf8de9347eb6135363 Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 30 Oct 2015 11:53:09 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-6016 - ensure xstream inits transients to default values when it bypasses the default creation method through object deserialization. Can make it more general if there are ever more instances of this. It avoids the need to check for null and sync --- .../java/org/apache/activemq/command/ConsumerInfo.java | 5 +++++ .../activemq/transport/xstream/XStreamWireFormat.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java index ed97a48b68..16e6f8c25e 100755 --- a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java +++ b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java @@ -527,4 +527,9 @@ public class ConsumerInfo extends BaseCommand { return result; } + public void initTransients() { + assignedGroupCount = new ConcurrentHashMap<>(); + lastDeliveredSequenceId = RemoveInfo.LAST_DELIVERED_UNSET; + } + } diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java b/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java index 7174fdf17a..f98fc61938 100755 --- a/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java @@ -24,6 +24,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.MarshallAware; import org.apache.activemq.command.MessageDispatch; import org.apache.activemq.transport.stomp.XStreamSupport; @@ -65,7 +66,11 @@ public class XStreamWireFormat extends TextWireFormat { @Override public Object unmarshalText(Reader reader) { - return getXStream().fromXML(reader); + Object val = getXStream().fromXML(reader); + if (val instanceof ConsumerInfo) { + ((ConsumerInfo)val).initTransients(); + } + return val; } @Override