DataBinder should use ConversionService if PropertyEditor cannot produce required type [SPR-13042] #17634
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Michał Sobkiewicz opened SPR-13042 and commented
When there is PropertyEditor registered for String, TypeConverterDelegate uses it to convert from every possible class... to String:
https://github.com/spring-projects/spring-framework/blob/v4.1.6.RELEASE/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java#L164
Thus, it doesn't even try to use custom ConversionService:
https://github.com/spring-projects/spring-framework/blob/v4.1.6.RELEASE/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java#L170
It makes no sense. IMHO, TypeConverterDelegate should use editors registered for types other than String (for instance, where there is PropertyEditor registered for Integer, it is ok to use it for String -> Integer and Integer -> String; however it is not ok to use it to convert MyEntity -> String).
Attached test is based on:
https://github.com/spring-projects/spring-framework/blob/v4.1.6.RELEASE/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java
If you want to show my use case, just let me know.
Affects: 4.1.6
Attachments:
Referenced from: commits 6418b54
The text was updated successfully, but these errors were encountered: