You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Benson Margulies (JIRA)" <ji...@apache.org> on 2008/05/18 04:15:55 UTC
[jira] Resolved: (CXF-1587) Aegis Databinding cannot handle
wildcard as a Map value type (ex: Map)
[ https://issues.apache.org/jira/browse/CXF-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benson Margulies resolved CXF-1587.
-----------------------------------
Resolution: Fixed
Fix Version/s: 2.1.1
Added test, fixed bug.
> Aegis Databinding cannot handle wildcard as a Map value type (ex: Map<String, ?>)
> ---------------------------------------------------------------------------------
>
> Key: CXF-1587
> URL: https://issues.apache.org/jira/browse/CXF-1587
> Project: CXF
> Issue Type: Bug
> Components: Aegis Databinding
> Affects Versions: 2.1
> Environment: Java 1.5.0_10; Windows
> Reporter: Brian Gadwell
> Assignee: Benson Margulies
> Fix For: 2.1.1
>
>
> If an interface conatins a method which takes a param of type Map<String, ?> or returns a Map<String, ?> the following exception occurs with the following code:
> ServerFactoryBean svrFactory = new ServerFactoryBean();
> svrFactory.setServiceClass(Tester.class);
> svrFactory.setAddress("http://localhost:9090/cxfbug");
> svrFactory.setServiceBean(new TesterImpl());
> svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
> svrFactory.create();
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
> at org.apache.cxf.aegis.type.java5.Java5TypeCreator.getComponentType(Java5TypeCreator.java:184)
> at org.apache.cxf.aegis.type.java5.Java5TypeCreator.getOrCreateParameterizedType(Java5TypeCreator.java:134)
> at org.apache.cxf.aegis.type.java5.Java5TypeCreator.getOrCreateMapValueType(Java5TypeCreator.java:130)
> at org.apache.cxf.aegis.type.AbstractTypeCreator.getOrCreateMapValueType(AbstractTypeCreator.java:254)
> at org.apache.cxf.aegis.type.XMLTypeCreator.getOrCreateMapValueType(XMLTypeCreator.java:514)
> at org.apache.cxf.aegis.type.AbstractTypeCreator.createMapType(AbstractTypeCreator.java:268)
> at org.apache.cxf.aegis.type.AbstractTypeCreator.createTypeForClass(AbstractTypeCreator.java:111)
> at org.apache.cxf.aegis.databinding.AegisDatabinding.getParameterType(AegisDatabinding.java:593)
> at org.apache.cxf.aegis.databinding.AegisDatabinding.initializeMessage(AegisDatabinding.java:375)
> at org.apache.cxf.aegis.databinding.AegisDatabinding.initializeOperation(AegisDatabinding.java:339)
> at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:303)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:343)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:394)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:180)
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79)
> at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:114)
> If you do not use the Aegis Databinding then the code works as expected.
> The problem seems to stem from the org.apache.cxf.aegis.type.java5.Java5TypeCrestor class in the following method:
> protected Class getComponentType(Object genericType, int index) {
> Class paramClass = null;
> if (genericType instanceof ParameterizedType) {
> ParameterizedType type = (ParameterizedType)genericType;
> if (type.getActualTypeArguments()[index] instanceof Class) {
> paramClass = (Class)type.getActualTypeArguments()[index];
> } else if (type.getActualTypeArguments()[index] instanceof WildcardType) {
> WildcardType wildcardType = (WildcardType)type.getActualTypeArguments()[index];
> if (wildcardType.getUpperBounds()[index] instanceof Class) {
> paramClass = (Class)wildcardType.getUpperBounds()[index];
> }
> } else if (type.getActualTypeArguments()[index] instanceof ParameterizedType) {
> ParameterizedType ptype = (ParameterizedType)type.getActualTypeArguments()[index];
> paramClass = (Class)ptype.getRawType();
> }
> }
> return paramClass;
> }
> I found if I change
> if (wildcardType.getUpperBounds()[index] instanceof Class) {
> paramClass = (Class)wildcardType.getUpperBounds()[index];
> }
> to
> if (wildcardType.getUpperBounds()[0] instanceof Class) {
> paramClass = (Class)wildcardType.getUpperBounds()[0];
> }
> it works in my case but not at all sure if this is the correct fix or if this should be expected to be supported.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.