Skip to content

Commit e7a53e3

Browse files
committed
Avoid stateful MethodParameter nesting level changes in MVC processing
1 parent e5de7d5 commit e7a53e3

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import javax.servlet.http.HttpServletResponse;
3131

3232
import org.springframework.core.MethodParameter;
33+
import org.springframework.core.ResolvableType;
3334
import org.springframework.http.HttpEntity;
3435
import org.springframework.http.HttpHeaders;
3536
import org.springframework.http.HttpOutputMessage;
@@ -67,11 +68,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
6768

6869
private static final UrlPathHelper DECODING_URL_PATH_HELPER = new UrlPathHelper();
6970

70-
static {
71-
RAW_URL_PATH_HELPER.setRemoveSemicolonContent(false);
72-
RAW_URL_PATH_HELPER.setUrlDecode(false);
73-
}
74-
7571
/* Extensions associated with the built-in message converters */
7672
private static final Set<String> WHITELISTED_EXTENSIONS = new HashSet<String>(Arrays.asList(
7773
"txt", "text", "yml", "properties", "csv",
@@ -81,6 +77,10 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
8177
private static final Set<String> WHITELISTED_MEDIA_BASE_TYPES = new HashSet<String>(
8278
Arrays.asList("audio", "image", "video"));
8379

80+
static {
81+
RAW_URL_PATH_HELPER.setRemoveSemicolonContent(false);
82+
RAW_URL_PATH_HELPER.setUrlDecode(false);
83+
}
8484

8585
private final ContentNegotiationManager contentNegotiationManager;
8686

@@ -266,19 +266,16 @@ protected Class<?> getReturnValueType(Object returnValue, MethodParameter return
266266
}
267267

268268
/**
269-
* Return the generic type of the {@code returnType} (or of the nested type if it is
270-
* a {@link HttpEntity}).
269+
* Return the generic type of the {@code returnType} (or of the nested type
270+
* if it is an {@link HttpEntity}).
271271
*/
272272
private Type getGenericType(MethodParameter returnType) {
273-
Type type;
274273
if (HttpEntity.class.isAssignableFrom(returnType.getParameterType())) {
275-
returnType.increaseNestingLevel();
276-
type = returnType.getNestedGenericParameterType();
274+
return ResolvableType.forType(returnType.getGenericParameterType()).getGeneric(0).getType();
277275
}
278276
else {
279-
type = returnType.getGenericParameterType();
277+
return returnType.getGenericParameterType();
280278
}
281-
return type;
282279
}
283280

284281
/**

0 commit comments

Comments
 (0)