Skip to content

ConversionService broken since 3.0.4 [SPR-7816] #12472

@spring-projects-issues

Description

@spring-projects-issues

Andrei Stefan opened SPR-7816 and commented

Snippet form class:

public FilterAdapter(final String expectedPrefix, final Map<String, Class<? extends DomainEntity>> supportedTypes) {
super();
this.expectedPrefix = expectedPrefix;
this.supportedTypes = supportedTypes;
}

Config in spring xml:

<bean id="filterAdapter" class="com.foo.FilterAdapter">
<constructor-arg value="building:"/>
<constructor-arg>
<map>
<entry key="Building" value="com.foo.Building"/>
<entry key="Entrance" value="com.foo.Entrance"/>
<entry key="Dwelling" value="com.foo.Dwelling"/>
</map>
</constructor-arg>
</bean>

Map values are not converted to java.lang.Class, they are injected as Strings.
Please note that this is when ConversionService is used, when you have somethings like this in your config:
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>

I've tested this in both 3.0.5 and 3.0.3 versions and the issue is there. I couldn't tell which change triggered this behavior, but judging by the MapToMapConverter class docs in 3.0.5:

"Converts a Map to another Map.
First, creates a new Map of the requested targetType with a size equal to the
size of the source Map. Then copies each element in the source map to the target map.
Will perform a conversion from the source maps's parameterized K,V types to the target
map's parameterized types K,V if necessary."

then this should work as it did in Spring 3.0.3, meaning converting the "com.foo.SomeClass" String to com.foo.SomeClass Class assuming here Spring should convert a Map<String, String> to a Map<String, Class<? extends SomeBaseClass>>.


Affects: 3.0.4, 3.0.5

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions