spr-7728: empty collection conversion can return value not assignable to targetType

This commit is contained in:
Keith Donald
2011-01-07 14:21:54 +00:00
parent a7293d2961
commit b040606cfa
4 changed files with 78 additions and 6 deletions

View File

@@ -62,9 +62,6 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
return null;
}
Collection<?> sourceCollection = (Collection<?>) source;
if (sourceCollection.isEmpty()) {
return sourceCollection;
}
Collection target = CollectionFactory.createCollection(targetType.getType(), sourceCollection.size());
for (Object sourceElement : sourceCollection) {
Object targetElement = this.conversionService.convert(sourceElement, sourceType.getElementTypeDescriptor().applyIndexedObject(sourceElement), targetType.getElementTypeDescriptor());

View File

@@ -67,9 +67,6 @@ final class MapToMapConverter implements ConditionalGenericConverter {
return null;
}
Map<?, ?> sourceMap = (Map<?, ?>) source;
if (sourceMap.isEmpty()) {
return sourceMap;
}
Map targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
for (Object entry : sourceMap.entrySet()) {
Map.Entry sourceMapEntry = (Map.Entry) entry;