bug in unmarshalling chained object references, fix included

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug in unmarshalling chained object references, fix included

Vladimir Tsichevski
Hi dev,

I use xstream-1.4.4, the latest stable release.

got the following exception trying to unmarshall an XML file.

com.thoughtworks.xstream.converters.ConversionException: Invalid reference
---- Debugging information ----
reference           : ../../Class2[257]/class3
class               : Class1
required-type       : Class1
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /list/Class1[169]/class3
class[1]            : java.util.ArrayList
converter-type[1]   : idm4j.clojure.xstream.proxy$com.thoughtworks.xstream.converters.collections.CollectionConverter$0
version             : null
-------------------------------
     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:57)
     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
     at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:355)
     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
     at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
     at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
     at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
     at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
     at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
  ...

The problematic part of XML looks like this (with my comments):

   <!-- Class2[257] -->
   <Class2>
     <!-- primary reference, resolved in cache, but not re-registered as Class1[257]/class3 -->
     <class3 reference="../../Class1[228]/class3"/>
   </Class2>
   <Class4>
     <!-- problematic reference, not in cache-->
     <class3 reference="../../Class2[257]/class3"/>
   </Class4>

The problem is that the reference class3 in the Class2[257] object is successfuly resolved in cache and the object found is NOT
registered as "Class2[257]/class3". The reference in the next entry is chained and cannot be resolved.

The fix: change the following lines in AbstractReferenceUnmarshaller.java:

if (cache == null) {
   final ConversionException ex = new ConversionException("Invalid reference");
   ex.add("reference", reference);
   throw ex;
   }
result = cache == NULL ? null : cache;

to

if (cache == null) {
   final ConversionException ex = new ConversionException("Invalid reference");
   ex.add("reference", reference);
   throw ex;
   }
result = cache;
values.put(getCurrentReferenceKey(), cache); // !!!

Regards,
Vladimir

PS: what is the right way to report bugs? JIRA site does not allows me to create an account :-(


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: bug in unmarshalling chained object references, fix included

Jörg Schaible-3
Hello Vladimir,

[snip]

thanks for the report ...

> PS: what is the right way to report bugs? JIRA site does not allows me to
> create an account :-(

.. but yes, you should create a JIRA issue. Meanwhile you need a *full*
account in xircles.codehaus.org for JIRA, the one used for mailing lists is
not sufficient.

Sorry for the inconvenience.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: bug in unmarshalling chained object references, fix included

Vladimir Tsichevski
Hi Jörg,

how can I get the *full* account? The Jira login page says:

   Not a member? To request an account, please contact your JIRA administrators.

Who it the administrators I shall contact?

Regards,
Vladimir

30.08.2013 13:06, Jörg Schaible wrote:

> Hello Vladimir,
>
> [snip]
>
> thanks for the report ...
>
>> PS: what is the right way to report bugs? JIRA site does not allows me to
>> create an account :-(
> .. but yes, you should create a JIRA issue. Meanwhile you need a *full*
> account in xircles.codehaus.org for JIRA, the one used for mailing lists is
> not sufficient.
>
> Sorry for the inconvenience.
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: bug in unmarshalling chained object references, fix included

Jörg Schaible-3
In reply to this post by Jörg Schaible-3
Hi Vladimir,

Vladimir Tsichevski wrote:

> Hi Jörg,
>
> how can I get the *full* account? The Jira login page says:
>
>    Not a member? To request an account, please contact your JIRA
>    administrators.

Sign up here:
http://xircles.codehaus.org/

> Who it the administrators I shall contact?

You're not the first with this problem, I've created finally a bug report:
http://jira.codehaus.org/browse/HAUS-2323

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email