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

This commit is contained in:
gtully 2015-10-30 11:53:09 +00:00
parent f8bfff0bc8
commit 8136e67b40
2 changed files with 11 additions and 1 deletions

View File

@ -527,4 +527,9 @@ public class ConsumerInfo extends BaseCommand {
return result;
}
public void initTransients() {
assignedGroupCount = new ConcurrentHashMap<>();
lastDeliveredSequenceId = RemoveInfo.LAST_DELIVERED_UNSET;
}
}

View File

@ -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