XStream
  1. XStream
  2. XSTR-737

Unable to ignore fields with predefined converters (such as <url>)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.x Maintenance
    • Fix Version/s: 1.4.5
    • Component/s: Core
    • Labels:
      None

      Description

      In the latest trunk code, it appears it's impossible to parse XML that contains unknown elements with predefined converters, such as <url>. I tried both ignoring them the old way, by overriding shouldSerializeMember with a "definedIn != Object.class" check, or the new way, calling xStream.ignoreUnknownElements().

      This is a blocker for us, because there's no workaround.

      Here's a self-contained unit test to reproduce this problem with XStream 1.4.5-20130321.143015-2:

      	public void testHandlingUnknownURLField() {
      		final XStream xStream = new XStream();
      		xStream.ignoreUnknownElements();
      		xStream.processAnnotations(MyTestClass.class);
      		
      		final String xmlWithNewField = "<myTestClass><id>123</id><url>http://www.google.com</url></myTestClass>";
      		
      		final MyTestClass c1 = (MyTestClass) xStream.fromXML(xmlWithNewField);
      		assertNotNull(c1);
      	}
      
      	@XStreamAlias("myTestClass")
      	public class MyTestClass implements Serializable {
      		public MyTestClass() {}
      	}
      

        People

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

          Dates

          • Created:
            Updated:
            Resolved: