Skip to content

Regression in Collection to array conversion [SPR-7496] #12154

@spring-projects-issues

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-7496 and commented

The following code doesn't work in 3.0.4 but used to work in 3.0.3:

FormattingConversionServiceFactoryBean factoryBean = new FormattingConversionServiceFactoryBean();
factoryBean.afterPropertiesSet();
ConversionService conversionService = factoryBean.getObject();
assertTrue(conversionService.canConvert(Collection.class, Integer[].class));

Output from 3.0.3:

TRACE: GenericConversionService - Checking if I can convert [TypeDescriptor java.util.Collection<?>] to [TypeDescriptor java.lang.Integer[]]
TRACE: GenericConversionService - Searching for converters indexed by sourceType [java.util.Collection]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Integer;]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Number;]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Object;]
TRACE: GenericConversionService - Found matchable converters CollectionToArrayConverter@b23b25c
TRACE: GenericConversionService - Matching CollectionToArrayConverter@b23b25c
TRACE: GenericConversionService - Checking if I can convert [TypeDescriptor.NULL] to [TypeDescriptor java.lang.Integer]
TRACE: GenericConversionService - Yes, I can convert
TRACE: GenericConversionService - Matched converter CollectionToArrayConverter@b23b25c
TRACE: GenericConversionService - Caching under ConverterCacheKey [sourceType = [TypeDescriptor java.util.Collection<?>], targetType = [TypeDescriptor java.lang.Integer[]]]
TRACE: GenericConversionService - Yes, I can convert

Output from 3.0.4 (truncated at the bottom):

TRACE: GenericConversionService - Checking if I can convert [TypeDescriptor java.util.Collection<java.lang.Object>] to [TypeDescriptor java.lang.Integer[]]
TRACE: GenericConversionService - Searching for converters indexed by sourceType [java.util.Collection]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Integer;]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Number;]
TRACE: GenericConversionService - and indexed by targetType [[Ljava.lang.Object;]
TRACE: GenericConversionService - Found matchable converters CollectionToArrayConverter@b23b25c
TRACE: GenericConversionService - Matching CollectionToArrayConverter@b23b25c
TRACE: GenericConversionService - Checking if I can convert [TypeDescriptor java.lang.Object] to [TypeDescriptor java.lang.Integer]
TRACE: GenericConversionService - Searching for converters indexed by sourceType [java.lang.Object]
TRACE: GenericConversionService - and indexed by targetType [java.lang.Integer]
TRACE: GenericConversionService - and indexed by targetType [java.lang.Comparable]
TRACE: GenericConversionService - and indexed by targetType [java.lang.Number]
TRACE: GenericConversionService - and indexed by targetType [java.io.Serializable]
TRACE: GenericConversionService - and indexed by targetType [java.lang.Object]
TRACE: GenericConversionService - Found matchable converters IdToEntityConverter@7546c1d4, ObjectToObjectConverter@785f8172
TRACE: GenericConversionService - Matching IdToEntityConverter@7546c1d4
TRACE: GenericConversionService - Did not match converter IdToEntityConverter@7546c1d4
TRACE: GenericConversionService - Matching ObjectToObjectConverter@785f8172
TRACE: GenericConversionService - Did not match converter ObjectToObjectConverter@785f8172
TRACE: GenericConversionService - Caching NO_MATCH under ConverterCacheKey [sourceType = [TypeDescriptor java.lang.Object], targetType = [TypeDescriptor java.lang.Integer]]
TRACE: GenericConversionService - No, I cannot convert
TRACE: GenericConversionService - Did not match converter CollectionToArrayConverter@b23b25c
...

Notice the difference in the TypeDescriptor built for the source in each case (line 1).


Affects: 3.0.4

Issue Links:

Referenced from: commits spring-projects/spring-webflow@cef35b6

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions