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

(cherry picked from commit 8136e67b40)
This commit is contained in:
gtully 2015-10-30 11:53:09 +00:00 committed by Christopher L. Shannon (cshannon)
parent b84785d5d0
commit c3339bc0fb
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;
@ -64,7 +65,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