Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2, 1.3
-
Fix Version/s: 1.3.1
-
Labels:None
-
Number of attachments :
Description
If an attribute is not a string, the MappedNamespaceConvention fails (see @made member, if its value is changed to "true" it works).
{"shot":{"@team": "1", "@player": "1", "@systemTime": "01:19:35", "@gameTime": "01:19:35", "@eventTime": "01:19:35.000", "@type": "4", "@x": "123", "@y": "55", "@made": true}}
java.lang.ClassCastException: java.lang.Boolean
at org.codehaus.jettison.mapped.MappedNamespaceConvention.processAttributesAndNamespaces(MappedNamespaceConvention.java:119)
at org.codehaus.jettison.Node.<init>(Node.java:55)
at org.codehaus.jettison.mapped.MappedXMLStreamReader.processElement(MappedXMLStreamReader.java:147)
at org.codehaus.jettison.mapped.MappedXMLStreamReader.next(MappedXMLStreamReader.java:77)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:332)
at com.xxx.livefeed.esb.TestComponent.transform(TestComponent.java:62)
at org.apache.servicemix.components.util.TransformComponentSupport.processFirstExchange(TransformComponentSupport.java:90)
at org.apache.servicemix.components.util.TransformComponentSupport.onMessageExchange(TransformComponentSupport.java:64)
at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:632)
at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:185)
at org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
at org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:613)
This bit me as well and caused a lot of things to break in my system when upgrading. Clients that used to send JSON boolean attributes without quotes (e.g. {"obj":{"@enabled":false}} suddenly started getting class cast exceptions.
I've implemented a simple fix for this. It changes
String strValue = (String) o;
to:
String strValue = (o == null ? null : o.toString());
This seems to work for the boolean attributes at least.