Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.6
-
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?