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
The algorithm implemented in GenericFormatterRegistry.findConverterByClassPair(Class, Class) apparently goes up the superinterface and superclass hierarchy to find a proper converter for a given source type. However, since the DefaultConversionService registers an ObjectToStringConverter, this converter will be preferred over specialized converters for interfaces.
Consider the following situation: class X implements the interface I which in turn is a subinterface of J. There is a special converter for J-to-String.
The classQueue will be filled in this case with
X
I (from X.getInterfaces())
Object (from X.getSuperclass())
J (from I.getInterfaces())
Since Object appears before J the generic ObjectToStringConverter will be used here instead of the more specific converter for J.
A more appropriate algorithm should probably consider first all interfaces before using the superclasses. In any case the ObjectToStringConverter should always be the last converter to be used.
Good point. I've revised this to consider all interfaces (including inherited interfaces) before going up the superclass hierarchy. This will be available in tonight's snapshot already.
Oliver Becker opened SPR-6297 and commented
The algorithm implemented in GenericFormatterRegistry.findConverterByClassPair(Class, Class) apparently goes up the superinterface and superclass hierarchy to find a proper converter for a given source type. However, since the DefaultConversionService registers an ObjectToStringConverter, this converter will be preferred over specialized converters for interfaces.
Consider the following situation: class X implements the interface I which in turn is a subinterface of J. There is a special converter for J-to-String.
The classQueue will be filled in this case with
Since Object appears before J the generic ObjectToStringConverter will be used here instead of the more specific converter for J.
A more appropriate algorithm should probably consider first all interfaces before using the superclasses. In any case the ObjectToStringConverter should always be the last converter to be used.
Affects: 3.0 RC1
Sub-tasks:
Issue Links:
Referenced from: commits 010e72c
The text was updated successfully, but these errors were encountered: