Workaround ResolvableType.forClassWithGenerics bug

Temporarily work around SPR-16456
pull/11886/head
Phillip Webb 7 years ago
parent 60d525e732
commit f24c92c658

@ -40,7 +40,7 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
AggregateElementBinder elementBinder) {
Class<?> collectionType = (target.getValue() == null ? target.getType().resolve()
: List.class);
ResolvableType aggregateType = ResolvableType.forClassWithGenerics(List.class,
ResolvableType aggregateType = forClassWithGenerics(List.class,
target.getType().asCollection().getGenerics());
ResolvableType elementType = target.getType().asCollection().getGeneric();
IndexedCollectionSupplier result = new IndexedCollectionSupplier(

@ -79,8 +79,8 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
ConfigurationProperty property = source.getConfigurationProperty(root);
if (property != null) {
Object aggregate = convert(property.getValue(), aggregateType);
ResolvableType collectionType = ResolvableType
.forClassWithGenerics(collection.get().getClass(), elementType);
ResolvableType collectionType = forClassWithGenerics(
collection.get().getClass(), elementType);
Collection<Object> elements = convert(aggregate, collectionType);
collection.get().addAll(elements);
}
@ -140,6 +140,17 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
return ResolvableTypeDescriptor.forType(type).convert(conversionService, value);
}
// Work around for SPR-16456
protected static ResolvableType forClassWithGenerics(Class<?> type,
ResolvableType... generics) {
ResolvableType[] resolvedGenerics = new ResolvableType[generics.length];
for (int i = 0; i < generics.length; i++) {
resolvedGenerics[i] = forClassWithGenerics(generics[i].resolve(),
generics[i].getGenerics());
}
return ResolvableType.forClassWithGenerics(type, resolvedGenerics);
}
/**
* {@link AggregateBinder.AggregateSupplier AggregateSupplier} for an indexed
* collection.

Loading…
Cancel
Save