提交 3e4810f6 编写于 作者: K Keith Donald

polish

上级 a0cab10c
......@@ -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();
......
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<String> bindTarget = new ArrayList<String>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册