polish
This commit is contained in:
parent
a0cab10ccc
commit
3e4810f670
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -71,6 +72,15 @@ public class CollectionToCollectionTests {
|
|||
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>();
|
||||
public List<Integer> integerTarget = new ArrayList<Integer>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue