XStream
  1. XStream
  2. XSTR-654

Unmarshall fails if there's an alias same as the value of an implicitCollection

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      Description

      For example:

      package com.test;
      public class Foo

      { List<Entry> entry; ... }

      package com.test;
      public class Entry

      { String prop; ... }

      Then I add alias and an implictCollection
      XStream xs = new XStream();
      xs.alias("foo", com.test.Foo.class);
      xs.alias("entry", com.test.Entry.class);

      xs.addImplicitCollection(com.test.Foo.class, "entry");

      When marshalling, it returns the xml as expected without the needless root <entry> element:
      something like:
      <foo>
      <entry>
      <prop>123</prop>
      </entry>
      <entry>
      <prop>123</prop>
      </entry>
      </foo>

      But, when unmarshalling from xml like above, it fails.

      Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: prop: prop: prop: prop
      ---- Debugging information ----
      message : prop: prop
      cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
      cause-message : prop: prop
      class : com.test.Foo
      required-type : java.lang.Object
      path : /foo/entry/prop
      line number : 4
      -------------------------------
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:89)
      at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:225)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
      at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:246)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:218)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
      at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)
      at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
      at com.thoughtworks.xstream.XStream.fromXML(XStream.java:845)
      at com.covisint.healthcare.cdr.CdrWrapperMirthUtils.main(CdrWrapperMirthUtils.java:72)
      Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: prop: prop
      at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
      at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:52)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:347)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:208)
      at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
      at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
      ... 22 more

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Grant
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: