cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bright Zheng (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-5509) NullPointerException if class with generic-array parameters is set to rootClassNames
Date Wed, 22 Jan 2014 08:42:24 GMT

     [ https://issues.apache.org/jira/browse/CXF-5509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Bright Zheng updated CXF-5509:
------------------------------

    Description: 
I want to expose a set of classes by setting the aegisContext:
{code:xml}
<bean id="aegisContext" class="org.apache.cxf.aegis.AegisContext" scope="prototype">
        <property name="writeXsiTypes" value="true"/>
        <property name="rootClassNames">
            <ref bean="bindingList"/>
        </property>
</bean>
{code}

One of the class in the list is as a response pojo which has generic-array field like:
{code:java}
public class Subject<T extends Score>{
...
	private T[] score;
        //and getter/setter also
...
{code}

During the deployment phase, while debugging with the CXF code, I found that below codes in
TypeUtil.java under cxf-rt-databinding-aegis-2.7.8.jar will case issue:
{code:java}
public static Class<?> getTypeRelatedClass(Type type) {
        Class<?> directClass = getTypeClass(type, false);
        if (directClass != null) {
            return directClass;
        }
        
        if (type instanceof ParameterizedType) {
            ParameterizedType pType = (ParameterizedType) type;
            return getTypeRelatedClass(pType.getRawType());
        }
        
        if (type instanceof GenericArrayType) {
            GenericArrayType gat = (GenericArrayType) type;
            Type compType = gat.getGenericComponentType();             
            Class<?> arrayBaseType = getTypeRelatedClass(compType);
            // believe it or not, this seems to be the only way to get the
            // Class object for an array of primitive type.
            Object instance = Array.newInstance(arrayBaseType, 0);
            return instance.getClass();
        }
        return null;
    }
{code}
{color:red}
Note: the arrayBaseType will always be null while initializing that class so it will cause
the next line of code NPE!!
{color}

Did I miss anything for this kind of class mapping while using aegis?


  was:
I want to expose a set of classes by setting the aegisContext:
{code:xml}
<bean id="aegisContext" class="org.apache.cxf.aegis.AegisContext" scope="prototype">
        <property name="writeXsiTypes" value="true"/>
        <property name="rootClassNames">
            <ref bean="bindingList"/>
        </property>
</bean>
{/code}

One of the class in the list is as a response pojo which has generic-array field like:
{code:java}
public class Subject<T extends Score>{
...
	private T[] score;
        //and getter/setter also
...
{code}

During the deployment phase, while debugging with the CXF code, I found that below codes in
TypeUtil.java under cxf-rt-databinding-aegis-2.7.8.jar will case issue:
{code:java}
public static Class<?> getTypeRelatedClass(Type type) {
        Class<?> directClass = getTypeClass(type, false);
        if (directClass != null) {
            return directClass;
        }
        
        if (type instanceof ParameterizedType) {
            ParameterizedType pType = (ParameterizedType) type;
            return getTypeRelatedClass(pType.getRawType());
        }
        
        if (type instanceof GenericArrayType) {
            GenericArrayType gat = (GenericArrayType) type;
            Type compType = gat.getGenericComponentType();             
            Class<?> arrayBaseType = getTypeRelatedClass(compType);
            // believe it or not, this seems to be the only way to get the
            // Class object for an array of primitive type.
            Object instance = Array.newInstance(arrayBaseType, 0);
            return instance.getClass();
        }
        return null;
    }
{code}
{color:red}
Note: the arrayBaseType will be always null while initializing that class os it will cause
the next line of code NPE!!
{color}

Did I miss anything for this kind of class mapping while using aegis?



> NullPointerException if class with generic-array parameters is set to rootClassNames
> ------------------------------------------------------------------------------------
>
>                 Key: CXF-5509
>                 URL: https://issues.apache.org/jira/browse/CXF-5509
>             Project: CXF
>          Issue Type: Bug
>          Components: Aegis Databinding
>    Affects Versions: 2.7.8
>         Environment: RHEL6.3 (64b), JDK1.6, Spring 3.0.6, CXF 2.7.8
>            Reporter: Bright Zheng
>              Labels: NPE, aegis, binding, cxf, generic
>
> I want to expose a set of classes by setting the aegisContext:
> {code:xml}
> <bean id="aegisContext" class="org.apache.cxf.aegis.AegisContext" scope="prototype">
>         <property name="writeXsiTypes" value="true"/>
>         <property name="rootClassNames">
>             <ref bean="bindingList"/>
>         </property>
> </bean>
> {code}
> One of the class in the list is as a response pojo which has generic-array field like:
> {code:java}
> public class Subject<T extends Score>{
> ...
> 	private T[] score;
>         //and getter/setter also
> ...
> {code}
> During the deployment phase, while debugging with the CXF code, I found that below codes
in TypeUtil.java under cxf-rt-databinding-aegis-2.7.8.jar will case issue:
> {code:java}
> public static Class<?> getTypeRelatedClass(Type type) {
>         Class<?> directClass = getTypeClass(type, false);
>         if (directClass != null) {
>             return directClass;
>         }
>         
>         if (type instanceof ParameterizedType) {
>             ParameterizedType pType = (ParameterizedType) type;
>             return getTypeRelatedClass(pType.getRawType());
>         }
>         
>         if (type instanceof GenericArrayType) {
>             GenericArrayType gat = (GenericArrayType) type;
>             Type compType = gat.getGenericComponentType();             
>             Class<?> arrayBaseType = getTypeRelatedClass(compType);
>             // believe it or not, this seems to be the only way to get the
>             // Class object for an array of primitive type.
>             Object instance = Array.newInstance(arrayBaseType, 0);
>             return instance.getClass();
>         }
>         return null;
>     }
> {code}
> {color:red}
> Note: the arrayBaseType will always be null while initializing that class so it will
cause the next line of code NPE!!
> {color}
> Did I miss anything for this kind of class mapping while using aegis?



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message