NPE writing entry of Map<String,Object>. Type for Map value java.lang.Object 
not determined from override types (fix included)
------------------------------------------------------------------------------------------------------------------------------

                 Key: XFIRE-861
                 URL: http://jira.codehaus.org/browse/XFIRE-861
             Project: XFire
          Issue Type: Bug
          Components: Aegis Module
    Affects Versions: 1.2.4
         Environment: RAD 6.01, XFire 1.2.4
            Reporter: Joost den Boer
         Assigned To: Dan Diephouse
         Attachments: AegisBindingProvider.java

When an object contains a (Hash)Map property which is configured in the Aegis 
binding of type <String,Object> , the real type of the value is not correctly 
determined. Aegis binding for property:
<property name="result" class="java.util.Hashtable" keyType="java.lang.String" 
componentType="java.lang.Object" />

The problem is in AegisBindingProvider.getWriteType( .. ). In this method, if 
the given type.getTypeClass() != value.getClass() , the overrideTypeList is 
retrieved from the service and checked to see if it includes the 
value.getClass(). If this is true, inside the if-block , nothing is done with 
the overrideTypeList. Only "type = 
type.getTypeMapping().getType(value.getClass());" is executed. When the type is 
ObjectType, the type mappings only contain the default mappings for int, 
boolean, float, etc, so this statement evaluates type to NULL. Later in 
MapType.writeEntry , a method is executed on the valueType (which is NULL) and 
this causes a NPE.

To solve this issue, I fixed the AegisBindingProvider.getWriteType( .. ) method 
by getting the correct type from the overrideTypeList in the if-block if the 
type == null.

Code added in if-block after "type = 
type.getTypeMapping().getType(value.getClass());" :
                // fix bug XFIRE-??
                // type can still be null if type instanceof ObjectType
                if(null == type) {
                        // get service type mapping from context
                        CustomTypeMapping serviceMapping = (CustomTypeMapping) 
context.getService().getProperty(TYPE_MAPPING_KEY);
                        // get type for value class
                        type = serviceMapping.getType(value.getClass());
                }
                // end fix

I added the complete listing of the AegisBindingProvider in the attachement

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to