History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-338
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Chris Ingham
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XStream

NPE in JsonHierarchicalStreamWriter.startNode(Class clazz) when clazz is null

Created: 30/Aug/06 06:31 PM   Updated: 09/Nov/06 05:05 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.1

File Attachments: 1. Text File json_writer_no_npe.patch (1 kb)
2. Java Source File XSTR338Test.java (0.5 kb)


JDK version and platform: Sun 1.5.0_06 for Windows


 Description  « Hide
Tried the experimental JSON support and ran into a NPE when ColorConverter attempts to marshall a Color.class instance as four ints, calling startNode(String) without the 2nd Class parameter:

Exception in thread "main" java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at com.thoughtworks.xstream.io.json.JsonHierarchicalStreamWriter.startNode(JsonHierarchicalStreamWriter.java:77)
at com.thoughtworks.xstream.io.json.JsonHierarchicalStreamWriter.startNode(JsonHierarchicalStreamWriter.java:58)
at com.thoughtworks.xstream.io.WriterWrapper.startNode(WriterWrapper.java:17)
at com.thoughtworks.xstream.io.path.PathTrackingWriter.startNode(PathTrackingWriter.java:25)
at com.thoughtworks.xstream.converters.extended.ColorConverter.write(ColorConverter.java:49)
at com.thoughtworks.xstream.converters.extended.ColorConverter.marshal(ColorConverter.java:29)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:59)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.marshallField(AnnotationReflectionConverter.java:37)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:105)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:81)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:109)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:41)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:59)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:73)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:745)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:734)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:715)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:705)
...

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Chris Ingham - 30/Aug/06 06:42 PM
JUnit test case

Chris Winters - 06/Sep/06 04:50 PM
Ensure a class is not null before checking if it's assignable from another class or it's an array.

Joerg Schaible - 08/Oct/06 11:50 AM
Patch Applied. Thanks!

Joerg Schaible - 09/Nov/06 05:05 PM
Closed as fixed for 1.2.1