@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2019 the original author or authors .
* Copyright 2002 - 2020 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -690,6 +690,27 @@ public class RequestResponseBodyMethodProcessorTests {
@@ -690,6 +690,27 @@ public class RequestResponseBodyMethodProcessorTests {
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor ( converters ) ;
assertThat ( processor . supportsParameter ( methodParameter ) ) . isTrue ( ) ;
String value = ( String ) processor . readWithMessageConverters (
this . request , methodParameter , methodParameter . getGenericParameterType ( ) ) ;
assertThat ( value ) . isEqualTo ( "foo" ) ;
}
@Test // gh-24127
public void resolveArgumentTypeVariableWithGenericInterfaceAndSubclass ( ) throws Exception {
this . servletRequest . setContent ( "\"foo\"" . getBytes ( "UTF-8" ) ) ;
this . servletRequest . setContentType ( MediaType . APPLICATION_JSON_VALUE ) ;
Method method = SubControllerImplementingInterface . class . getMethod ( "handle" , Object . class ) ;
HandlerMethod handlerMethod = new HandlerMethod ( new SubControllerImplementingInterface ( ) , method ) ;
MethodParameter methodParameter = handlerMethod . getMethodParameters ( ) [ 0 ] ;
List < HttpMessageConverter < ? > > converters = new ArrayList < > ( ) ;
converters . add ( new MappingJackson2HttpMessageConverter ( ) ) ;
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor ( converters ) ;
assertThat ( processor . supportsParameter ( methodParameter ) ) . isTrue ( ) ;
String value = ( String ) processor . readWithMessageConverters (
this . request , methodParameter , methodParameter . getGenericParameterType ( ) ) ;
assertThat ( value ) . isEqualTo ( "foo" ) ;
@ -1041,4 +1062,13 @@ public class RequestResponseBodyMethodProcessorTests {
@@ -1041,4 +1062,13 @@ public class RequestResponseBodyMethodProcessorTests {
static class MyControllerImplementingInterface implements MappingInterface < String > {
}
static class SubControllerImplementingInterface extends MyControllerImplementingInterface {
@Override
public String handle ( String arg ) {
return arg ;
}
}
}