Skip to content

Commit

Permalink
Avoid stateful MethodParameter nesting level changes in MVC processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 2, 2016
1 parent e5de7d5 commit e7a53e3
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
Expand Down Expand Up @@ -30,6 +30,7 @@
import javax.servlet.http.HttpServletResponse;

import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpOutputMessage;
Expand Down Expand Up @@ -67,11 +68,6 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe

private static final UrlPathHelper DECODING_URL_PATH_HELPER = new UrlPathHelper();

static {
RAW_URL_PATH_HELPER.setRemoveSemicolonContent(false);
RAW_URL_PATH_HELPER.setUrlDecode(false);
}

/* Extensions associated with the built-in message converters */
private static final Set<String> WHITELISTED_EXTENSIONS = new HashSet<String>(Arrays.asList(
"txt", "text", "yml", "properties", "csv",
Expand All @@ -81,6 +77,10 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
private static final Set<String> WHITELISTED_MEDIA_BASE_TYPES = new HashSet<String>(
Arrays.asList("audio", "image", "video"));

static {
RAW_URL_PATH_HELPER.setRemoveSemicolonContent(false);
RAW_URL_PATH_HELPER.setUrlDecode(false);
}

private final ContentNegotiationManager contentNegotiationManager;

Expand Down Expand Up @@ -266,19 +266,16 @@ protected Class<?> getReturnValueType(Object returnValue, MethodParameter return
}

/**
* Return the generic type of the {@code returnType} (or of the nested type if it is
* a {@link HttpEntity}).
* Return the generic type of the {@code returnType} (or of the nested type
* if it is an {@link HttpEntity}).
*/
private Type getGenericType(MethodParameter returnType) {
Type type;
if (HttpEntity.class.isAssignableFrom(returnType.getParameterType())) {
returnType.increaseNestingLevel();
type = returnType.getNestedGenericParameterType();
return ResolvableType.forType(returnType.getGenericParameterType()).getGeneric(0).getType();
}
else {
type = returnType.getGenericParameterType();
return returnType.getGenericParameterType();
}
return type;
}

/**
Expand Down

0 comments on commit e7a53e3

Please sign in to comment.