Shared read-only instances of UrlPathHelper
UrlPathHelper is often created and used without customizations or with the same customizations. This commit introduces re-usable, instances. Effectively a backport of commit 23233c. See gh-25690
This commit is contained in:
@@ -83,9 +83,6 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
public class MockHttpServletRequestBuilder
|
||||
implements ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>, Mergeable {
|
||||
|
||||
private static final UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||
|
||||
|
||||
private final String method;
|
||||
|
||||
private final URI url;
|
||||
@@ -781,7 +778,7 @@ public class MockHttpServletRequestBuilder
|
||||
}
|
||||
String extraPath = requestUri.substring(this.contextPath.length() + this.servletPath.length());
|
||||
this.pathInfo = (StringUtils.hasText(extraPath) ?
|
||||
urlPathHelper.decodeRequestString(request, extraPath) : null);
|
||||
UrlPathHelper.defaultInstance.decodeRequestString(request, extraPath) : null);
|
||||
}
|
||||
request.setPathInfo(this.pathInfo);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -45,8 +45,6 @@ final class PatternMappingFilterProxy implements Filter {
|
||||
|
||||
private static final String PATH_MAPPING_PATTERN = "/*";
|
||||
|
||||
private static final UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||
|
||||
private final Filter delegate;
|
||||
|
||||
/** Patterns that require an exact match, e.g. "/test" */
|
||||
@@ -96,7 +94,7 @@ final class PatternMappingFilterProxy implements Filter {
|
||||
throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||
String requestPath = urlPathHelper.getPathWithinApplication(httpRequest);
|
||||
String requestPath = UrlPathHelper.defaultInstance.getPathWithinApplication(httpRequest);
|
||||
|
||||
if (matches(requestPath)) {
|
||||
this.delegate.doFilter(request, response, filterChain);
|
||||
|
||||
Reference in New Issue
Block a user