Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inadequate implementation of GenericConversionService.findConverterByClassPair(Class, Class) [SPR-6297] #10963

Closed
spring-projects-issues opened this issue Nov 3, 2009 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 3, 2009

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

  • 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.


Affects: 3.0 RC1

Sub-tasks:

Issue Links:

Referenced from: commits 010e72c

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

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.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants