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

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3883 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Keith Donald
2011-01-07 14:21:54 +00:00
parent 5a7d2a91ba
commit c45f4b1caf
4 changed files with 78 additions and 6 deletions
@@ -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());
@@ -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;