INT-1974 removed the IF statement which was checking the state of the collection in favor of delegating to the ConversionService
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package org.springframework.integration.util;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.SimpleTypeConverter;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.support.ConversionServiceFactory;
|
||||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -99,11 +97,6 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
|
||||
if (targetType.getType() == Void.class || targetType.getType() == Void.TYPE) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Collection<?>
|
||||
&& CollectionUtils.isEmpty((Collection<?>) value)
|
||||
&& Collection.class.isAssignableFrom(targetType.getObjectType())){
|
||||
return value;
|
||||
}
|
||||
if (conversionService.canConvert(sourceType, targetType)) {
|
||||
return conversionService.convert(value, sourceType, targetType);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ public class BeanFactoryTypeConverterTests {
|
||||
public void testEmptyCollectionConversion(){
|
||||
BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
|
||||
List<String> sourceObject = new ArrayList<String>();
|
||||
// source type doesn't even matter
|
||||
ArrayList<BeanFactoryTypeConverterTests> convertedCollection =
|
||||
(ArrayList<BeanFactoryTypeConverterTests>) typeConverter.convertValue(sourceObject, null, TypeDescriptor.forObject(new ArrayList<BeanFactoryTypeConverterTests>()));
|
||||
(ArrayList<BeanFactoryTypeConverterTests>) typeConverter.convertValue(sourceObject, TypeDescriptor.forObject(sourceObject), TypeDescriptor.forObject(new ArrayList<BeanFactoryTypeConverterTests>()));
|
||||
assertEquals(sourceObject, convertedCollection);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user