You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading a project from Spring 3.1.4 to 4.1.6, values set from property files via PropertyFactoryBean do not get converted to the destination type anymore.
Sample:
content of enum.properties
level.warn=WARN
level.info=INFO
level.error=ERROR
enum Level { WARN, INFO, ERROR }
class TestBean {
private Map<String,Level> levelMap;
Could you try to isolate a test case for this, please? Binding to generically typed Maps does work in general, so it's probably something subtle in your overall arrangement...
The problem here is the new implementation of TypeDescriptor.narrow in Spring 4.x, based on ResolvableType now: We're losing the originally declared key and value types when the type gets narrowed to java.util.Properties which is explicitly declared as Map<Object, Object> itself. This may show negative effects in other scenarios as well, so definitely needs to be fixed for 4.2.1 and 4.1.8.
After further research, TypeDescriptor.narrow actually behaves as it should, in particular for its use with SpEL. Instead, it's BeanWrapper's TypeConverterDelegate which appears to pointlessly call narrow without any actual need to. I've removed those calls for 4.2.1 now but refrain from backporting this to 4.1.8 due to potential side effects.
Robert Thaler opened SPR-13256 and commented
After upgrading a project from Spring 3.1.4 to 4.1.6, values set from property files via PropertyFactoryBean do not get converted to the destination type anymore.
Sample:
content of enum.properties
level.warn=WARN
level.info=INFO
level.error=ERROR
enum Level { WARN, INFO, ERROR }
class TestBean {
private Map<String,Level> levelMap;
}
Instead of the expected value type Level a map with String values is set by spring.
Affects: 4.1.6, 4.1.7
Attachments:
Referenced from: commits d4a23b8
The text was updated successfully, but these errors were encountered: