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
{{ message }}
Repository navigation
Differentiate between TypeDescriptors with same annotations but different attributes [SPR-13714] #18287
The current implementation of TypeDescriptor.equals only checks for the presence of matching annotations when comparing two type descriptors (as apposed to testing property values for the same annotation on both type descriptors). This ultimately leads to problems when used with the GenericConversionService cache as the service can return the wrong converter when multiple converters are being used that rely on annotations with distinct property values.
As far as I can see, this is actually intentional: Converters are usually triggered by a specific annotation type and then process the specific annotation attributes for each invocation; see e.g. AnnotationFormatterFactory. For that purpose, caching converters per annotation type is optimal.
That said, I do see the point that registering converters for specific annotation attribute values would be nice to have. I'll turn this into an improvement ticket for the 4.3 timeframe, assuming that we're able to accept the cache overhead of one entry per attribute combination then.
Rolled in a slightly revised form, including the suggested TypeDescriptorTests unit test as well as an actual test for converter matching in GenericConversionServiceTests.
Activity
spring-projects-issues commentedon Nov 21, 2015
Nathan Piper commented
I have submitted a fix in this pull request:
#924
spring-projects-issues commentedon Nov 23, 2015
Juergen Hoeller commented
As far as I can see, this is actually intentional: Converters are usually triggered by a specific annotation type and then process the specific annotation attributes for each invocation; see e.g.
AnnotationFormatterFactory. For that purpose, caching converters per annotation type is optimal.That said, I do see the point that registering converters for specific annotation attribute values would be nice to have. I'll turn this into an improvement ticket for the 4.3 timeframe, assuming that we're able to accept the cache overhead of one entry per attribute combination then.
Juergen
spring-projects-issues commentedon Dec 18, 2015
Juergen Hoeller commented
Rolled in a slightly revised form, including the suggested
TypeDescriptorTestsunit test as well as an actual test for converter matching inGenericConversionServiceTests.Juergen