org.springframework.core.TypeDescriptor.getAnnotations() should return the method annotation when it wraps the return parameter of the Method [SPR-6979] #11644
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Thomas Scheiblauer opened SPR-6979 and commented
If a TypeDescriptor is created from the return parameter of a method e.g.
TypeDescriptor typeDescr = new TypeDescriptor(new MethodParameter(method, -1))
where -1 denotes the return parameter then
typeDescr.getAnnotations() should return the annotations applied to the method.
3.0.1 crashes with an array index out of bounds exception because the called MethodParameter.getParameterAnnotations() tries to index an empty Annotations Array with -1,
the current 3.0.2 nightly fixes at least the exception by returning an empty Array in this case.
Since e.g. org.springframework.core.convert.ConversionService or org.codehaus.jackson.map.JsonSerializer<Object> need the TypeDescriptor for type conversions either MethodParameter.getParameterAnnotations() or TypeDescriptor.getAnnotations() should return the method annotations in case of a wrapped return parameter.
I bumped into this problem while trying to modify the getTypeDescriptorForSerializer method in this mvc ajax example:
https://src.springframework.org/svn/spring-samples/mvc-ajax/trunk/src/main/java/org/springframework/samples/mvc/ajax/json/FormatAnnotationIntrospector.java
according to the TODO note.
Affects: 3.0.1, 3.0.2
Attachments:
Referenced from: commits 65b0a8f
The text was updated successfully, but these errors were encountered: