|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -690,6 +690,27 @@ public void resolveArgumentTypeVariableWithGenericInterface() throws Exception {
|
690 | 690 |
|
691 | 691 | RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
|
692 | 692 |
|
| 693 | + assertThat(processor.supportsParameter(methodParameter)).isTrue(); |
| 694 | + String value = (String) processor.readWithMessageConverters( |
| 695 | + this.request, methodParameter, methodParameter.getGenericParameterType()); |
| 696 | + assertThat(value).isEqualTo("foo"); |
| 697 | + } |
| 698 | + |
| 699 | + @Test // gh-24127 |
| 700 | + public void resolveArgumentTypeVariableWithGenericInterfaceAndSubclass() throws Exception { |
| 701 | + this.servletRequest.setContent("\"foo\"".getBytes("UTF-8")); |
| 702 | + this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE); |
| 703 | + |
| 704 | + Method method = SubControllerImplementingInterface.class.getMethod("handle", Object.class); |
| 705 | + HandlerMethod handlerMethod = new HandlerMethod(new SubControllerImplementingInterface(), method); |
| 706 | + MethodParameter methodParameter = handlerMethod.getMethodParameters()[0]; |
| 707 | + |
| 708 | + List<HttpMessageConverter<?>> converters = new ArrayList<>(); |
| 709 | + converters.add(new MappingJackson2HttpMessageConverter()); |
| 710 | + |
| 711 | + RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters); |
| 712 | + |
| 713 | + assertThat(processor.supportsParameter(methodParameter)).isTrue(); |
693 | 714 | String value = (String) processor.readWithMessageConverters(
|
694 | 715 | this.request, methodParameter, methodParameter.getGenericParameterType());
|
695 | 716 | assertThat(value).isEqualTo("foo");
|
@@ -1041,4 +1062,13 @@ default A handle(@RequestBody A arg) {
|
1041 | 1062 | static class MyControllerImplementingInterface implements MappingInterface<String> {
|
1042 | 1063 | }
|
1043 | 1064 |
|
| 1065 | + |
| 1066 | + static class SubControllerImplementingInterface extends MyControllerImplementingInterface { |
| 1067 | + |
| 1068 | + @Override |
| 1069 | + public String handle(String arg) { |
| 1070 | + return arg; |
| 1071 | + } |
| 1072 | + } |
| 1073 | + |
1044 | 1074 | }
|
0 commit comments