Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2695

NullPointerException when reading a soap encoded struct with a nested element that's nil

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.6
    • 2.2.8
    • Aegis Databinding
    • None

    Description

      When reading a simple struct that has a nested (unqualified) element set to nil a NullPointerException is thrown:

      java.lang.NullPointerException
      	at org.apache.cxf.aegis.type.basic.BeanTypeInfo.isNillable(BeanTypeInfo.java:384)
      	at org.apache.cxf.aegis.type.basic.BeanType.readObject(BeanType.java:165)
      

      This should be easily replicated by using the following xml for the StructTypeTest.testSimpleStruct() test:

      <b:shipping xmlns:b="urn:Bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <street>1234 Riverside Drive</street>
          <city>Gainesville</city>
          <state>FL</state>
          <zip xsi:nil="true"/>
      </b:shipping>
      

      Apparently the problem stems from the fact that when the element is nil it's handled without involving the StructType (which takes care of "qualifying" the element name in other cases) - the unqualified name of the element is sent to the BeanTypeInfo.isNillable() method, which fails to find a Type for the name as a result.

      I'm not sure how to solve this in a "clean" way - maybe extracting the "else" block that handles nil elements in BeanType.readObject to a seperate overridable method thereby giving StructType a chance to qualify the name before it's sent to the BeanTypeInfo.isNillable() method?

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            marino_jonsson@hotmail.com Marinó A. Jónsson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: