From 3e4810f6707e127f5bb3fd71acbee78a97324be8 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 9 Apr 2009 14:09:10 +0000 Subject: [PATCH] polish --- .../core/convert/service/CollectionToArray.java | 2 +- .../core/convert/service/CollectionToCollection.java | 2 +- .../convert/service/CollectionToCollectionTests.java | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java b/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java index fc557309bd..796982468d 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java @@ -57,7 +57,7 @@ class CollectionToArray extends AbstractCollectionConverter { private ConversionExecutor getElementConverter(Collection source) { ConversionExecutor elementConverter = getElementConverter(); - if (elementConverter == NoOpConversionExecutor.INSTANCE && !source.isEmpty()) { + if (elementConverter == NoOpConversionExecutor.INSTANCE) { Iterator it = source.iterator(); while (it.hasNext()) { Object value = it.next(); diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java b/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java index ea7f15966c..a5921926cb 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java @@ -49,7 +49,7 @@ class CollectionToCollection extends AbstractCollectionConverter { private ConversionExecutor getElementConverter(Collection source) { ConversionExecutor elementConverter = getElementConverter(); - if (elementConverter == NoOpConversionExecutor.INSTANCE && !source.isEmpty() && getTargetElementType() != null) { + if (elementConverter == NoOpConversionExecutor.INSTANCE && getTargetElementType() != null) { Iterator it = source.iterator(); while (it.hasNext()) { Object value = it.next(); diff --git a/org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java b/org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java index 3126e8b679..34b56d08a8 100644 --- a/org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java +++ b/org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java @@ -1,6 +1,7 @@ package org.springframework.core.convert.service; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Collection; @@ -70,6 +71,15 @@ public class CollectionToCollectionTests { assertEquals(null, result.get(3)); assertEquals(new Integer(3), result.get(4)); } + + @Test + public void testCollectionToCollectionConversionNoGenericInfoSourceEmpty() throws Exception { + DefaultConversionService service = new DefaultConversionService(); + CollectionToCollection c = new CollectionToCollection(TypeDescriptor.valueOf(Collection.class), + new TypeDescriptor(getClass().getField("integerTarget")), service); + List result = (List) c.execute(bindTarget); + assertTrue(result.isEmpty()); + } public Collection bindTarget = new ArrayList();