Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-5768

XStream round-trip fails for classes with fields containing "__"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • core
    • None

      If a class has "__" in a field name, Hudson is not able to do correct round-trip marshaling and unmarshaling. This seems to be related to the fact that XStream2.useXStream11XmlFriendlyMapper() is overridden to return "true". If that flag is changed back to false, the round-trip works correctly (but the testCompatibilityFromString() test in hudson.util.SecretTest starts failing unless "$" is replaced with "_-" instead of "-" in the test).
      
      I believe this failure is happening because Hudson's XStream instance has both an XmlFriendlyReplacer and and XmlFriendlyMapper in the pipeline. This makes it so that the Mapper.realMember() call in RobustReflectionConverter strips underscores from an element name that has already had the underscores stripped before being returned by reader.getNodeName().
      
      In addition to this problem, we were futher impacted by this issue because the field in question was insider of a Throwable object. It turns out that the ThrowableConverter in XStream uses the internal ReflectionConverter directly, so that means that RobustReflectionConverter is not used when drilling into a Throwable. I'll create a separate JIRA ticket for this part of problem.
      
      The attached patch adds a failing test to XStream2Test. I'm not sure what the proper way to fix this would be.
      

            mindless Alan Harder
            md5 Mike Dillon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: