From ea728b15c8bd2b4d71387169aa217937b93d0730 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 1 Jun 2016 22:01:32 +0200 Subject: [PATCH] Polishing --- .../web/filter/ForwardedHeaderFilter.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java index 25225d74baf..99253ace772 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java @@ -39,7 +39,6 @@ import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UrlPathHelper; - /** * Filter that wraps the request in order to override its * {@link HttpServletRequest#getServerName() getServerName()}, @@ -70,19 +69,15 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { private ContextPathHelper contextPathHelper; - /** - * Configure a contextPath override that will replace the contextPath of + * Configure a context path override that will replace the context path of * proxy-forwarded requests. This is useful when external clients are not * aware of the application context path to which the proxy is configured * to forward to. - * *

For example, a client may connect to a proxy at:
* {@code https://example.com/} - * *

In turn the proxy forwards to the application at:
* {@code 192.168.1.1:8080/example/} - * * @param contextPath the context path; the given value will be sanitized to * ensure it starts with a '/' but does not end with one, or if the context * path is empty (default, root context) it is left as-is. @@ -141,7 +136,6 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { private final Map> headers; - public ForwardedHeaderRequestWrapper(HttpServletRequest request, ContextPathHelper pathHelper) { super(request); @@ -160,7 +154,6 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { this.headers = initHeaders(request); } - private static String initContextPath(HttpServletRequest request, ContextPathHelper pathHelper) { String contextPath = (pathHelper != null ? pathHelper.getContextPath(request) : request.getContextPath()); return prependForwardedPrefix(request, contextPath); @@ -206,7 +199,6 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { return value; } - @Override public String getScheme() { return this.scheme; @@ -303,7 +295,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { if (this.contextPath.equals("/") && pathWithinApplication.startsWith("/")) { return pathWithinApplication; } - return this.contextPath + pathWithinApplication; + return (this.contextPath + pathWithinApplication); } }