Browse Source

polish

pull/23217/head
Keith Donald 17 years ago
parent
commit
3e4810f670
  1. 2
      org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java
  2. 2
      org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java
  3. 10
      org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java

2
org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToArray.java

@ -57,7 +57,7 @@ class CollectionToArray extends AbstractCollectionConverter { @@ -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();

2
org.springframework.core/src/main/java/org/springframework/core/convert/service/CollectionToCollection.java

@ -49,7 +49,7 @@ class CollectionToCollection extends AbstractCollectionConverter { @@ -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();

10
org.springframework.core/src/test/java/org/springframework/core/convert/service/CollectionToCollectionTests.java

@ -1,6 +1,7 @@ @@ -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 { @@ -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<String> bindTarget = new ArrayList<String>();

Loading…
Cancel
Save