Skip to content

3.0.6 Map to Map conversion shallow copying maps causing unexpected results on upgrade from 3.0.5 [SPR-8714] #13356

@spring-projects-issues

Description

@spring-projects-issues

Ricardo Gladwell opened SPR-8714 and commented

We have created a AbstractMap sub-class, SoftExpireHashMap. This has configurable behaviour which is achieved by setting properties. Once the SoftExpireHashMap has been configured, it must have the init() method called on it so that it can start a thread executor which runs in the background periodically pruning expired cached items.

However, using the default converters included with the 3.0.6 version of org.springframework.format.support.FormattingConversionServiceFactoryBean we find that this Map is being shallow copied before being injected into our objects and is, hence, not initialised.

Please see the following test case that replicates this issue:

https://github.com/rgladwell/spring-map-converter-issue

For some reason the MapToMapConverter is copying this Map despite the fact we don't want any conversions carried out on it.

Workaround: We can eliminate this behaviour by calling FormatterRegistry.removeConvertible(Map.class, Map.class) but obviously this is problem if we ever do need Map to Map conversion.


Affects: 3.0.6

Issue Links:

Referenced from: commits c9607fd, cb5954e

1 votes, 2 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