ignore unknown fields in openwire commands to allow interop between
openwire versions.
This commit is contained in:
Timothy Bish 2013-11-13 10:36:02 -05:00
parent 6ed8f43d8d
commit 5e5458ec38
2 changed files with 14 additions and 6 deletions

View File

@ -19,13 +19,13 @@ package org.apache.activemq.transport.xstream;
import java.io.IOException;
import java.io.Reader;
import com.thoughtworks.xstream.XStream;
import org.apache.activemq.command.Command;
import org.apache.activemq.command.MarshallAware;
import org.apache.activemq.command.MessageDispatch;
import org.apache.activemq.transport.util.TextWireFormat;
import org.apache.activemq.wireformat.WireFormat;
import com.thoughtworks.xstream.XStream;
/**
* A {@link WireFormat} implementation which uses the <a
* href="http://xstream.codehaus.org/>XStream</a> library to marshall commands
@ -37,10 +37,12 @@ public class XStreamWireFormat extends TextWireFormat {
private XStream xStream;
private int version;
@Override
public int getVersion() {
return version;
}
@Override
public void setVersion(int version) {
this.version = version;
}
@ -49,14 +51,17 @@ public class XStreamWireFormat extends TextWireFormat {
return new XStreamWireFormat();
}
@Override
public Object unmarshalText(String text) {
return (Command)getXStream().fromXML(text);
return getXStream().fromXML(text);
}
@Override
public Object unmarshalText(Reader reader) {
return (Command)getXStream().fromXML(reader);
return getXStream().fromXML(reader);
}
@Override
public String marshalText(Object command) throws IOException {
if (command instanceof MarshallAware) {
((MarshallAware)command).beforeMarshall(this);
@ -105,7 +110,9 @@ public class XStreamWireFormat extends TextWireFormat {
// Implementation methods
// -------------------------------------------------------------------------
protected XStream createXStream() {
return new XStream();
XStream xstream = new XStream();
xstream.ignoreUnknownElements();
return xstream;
}
}

View File

@ -26,7 +26,6 @@ import java.util.Map;
import javax.jms.JMSException;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import org.apache.activemq.advisory.AdvisorySupport;
import org.apache.activemq.broker.BrokerContext;
import org.apache.activemq.broker.BrokerContextAware;
@ -42,6 +41,7 @@ import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XppReader;
import com.thoughtworks.xstream.io.xml.xppdom.XppFactory;
@ -253,6 +253,7 @@ public class JmsFrameTranslator extends LegacyFrameTranslator implements
if (xstream == null) {
xstream = new XStream();
xstream.ignoreUnknownElements();
}
// For any object whose elements contains an UTF8Buffer instance instead of a String