@ -692,6 +692,25 @@ public class RequestResponseBodyMethodProcessorTests {
@@ -692,6 +692,25 @@ public class RequestResponseBodyMethodProcessorTests {
assertEquals ( "UTF-8" , this . servletResponse . getCharacterEncoding ( ) ) ;
}
@Test // SPR-14520
public void resolveArgumentTypeVariableWithGenericInterface ( ) throws Exception {
this . servletRequest . setContent ( "\"foo\"" . getBytes ( "UTF-8" ) ) ;
this . servletRequest . setContentType ( MediaType . APPLICATION_JSON_UTF8_VALUE ) ;
Method method = MyControllerImplementingInterface . class . getMethod ( "handle" , Object . class ) ;
HandlerMethod handlerMethod = new HandlerMethod ( new MyControllerImplementingInterface ( ) , method ) ;
MethodParameter methodParameter = handlerMethod . getMethodParameters ( ) [ 0 ] ;
List < HttpMessageConverter < ? > > converters = new ArrayList < > ( ) ;
converters . add ( new MappingJackson2HttpMessageConverter ( ) ) ;
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor ( converters ) ;
String value = ( String ) processor . readWithMessageConverters ( this . request , methodParameter ,
methodParameter . getGenericParameterType ( ) ) ;
assertEquals ( "foo" , value ) ;
}
private void assertContentDisposition ( RequestResponseBodyMethodProcessor processor ,
boolean expectContentDisposition , String requestURI , String comment ) throws Exception {
@ -1011,4 +1030,13 @@ public class RequestResponseBodyMethodProcessorTests {
@@ -1011,4 +1030,13 @@ public class RequestResponseBodyMethodProcessorTests {
}
}
interface MappingInterface < A > {
default A handle ( @RequestBody A arg ) {
return arg ;
}
}
static class MyControllerImplementingInterface implements MappingInterface < String > {
}
}