Consistent type variable resolution for arrays/collections (in particular at field level)

Dropping GenericCollectionTypeResolver in favor of direct ResolvableType usage.

Issue: SPR-15160
This commit is contained in:
Juergen Hoeller
2017-01-24 18:00:17 +01:00
parent e8776f80da
commit 5e946c2700
13 changed files with 279 additions and 523 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,8 +57,8 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.CollectionFactory;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.jmx.support.JmxUtils;
import org.springframework.jmx.support.ObjectNameManager;
import org.springframework.util.ClassUtils;
@@ -546,7 +546,8 @@ public class MBeanClientInterceptor
return convertDataArrayToTargetArray(array, targetClass);
}
else if (Collection.class.isAssignableFrom(targetClass)) {
Class<?> elementType = GenericCollectionTypeResolver.getCollectionParameterType(parameter);
Class<?> elementType =
ResolvableType.forMethodParameter(parameter).asCollection().resolveGeneric();
if (elementType != null) {
return convertDataArrayToTargetCollection(array, targetClass, elementType);
}
@@ -562,7 +563,8 @@ public class MBeanClientInterceptor
return convertDataArrayToTargetArray(array, targetClass);
}
else if (Collection.class.isAssignableFrom(targetClass)) {
Class<?> elementType = GenericCollectionTypeResolver.getCollectionParameterType(parameter);
Class<?> elementType =
ResolvableType.forMethodParameter(parameter).asCollection().resolveGeneric();
if (elementType != null) {
return convertDataArrayToTargetCollection(array, targetClass, elementType);
}