Cache lookup path in ResourceUrlEncodingFilter
Commit https://github.com/spring-projects/spring-framework/commit/2b97d6 introduced a change where the path within the DispatcherServlet is determined with each call to ResourceUrlProvider.getForRequestUrl. To avoid repeating that every time a URL is encoded through the response, we now cache the result of the lookupPath determination in ResourceUrlEncodingFilter. Issue: SPR-12332
This commit is contained in:
@@ -79,7 +79,7 @@ public class ResourceUrlProviderJavaConfigTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolvePathWithServletMappingByPrefix() throws Exception {
|
||||
public void resolvePathWithServletMappedByPrefix() throws Exception {
|
||||
this.request.setRequestURI("/myapp/myservlet/index");
|
||||
this.request.setServletPath("/myservlet");
|
||||
this.filterChain.doFilter(this.request, this.response);
|
||||
@@ -88,6 +88,16 @@ public class ResourceUrlProviderJavaConfigTests {
|
||||
resolvePublicResourceUrlPath("/myapp/myservlet/resources/foo.css"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolvePathNoMatch() throws Exception {
|
||||
this.request.setRequestURI("/myapp/myservlet/index");
|
||||
this.request.setServletPath("/myservlet");
|
||||
this.filterChain.doFilter(this.request, this.response);
|
||||
|
||||
assertEquals("/myapp/myservlet/index", resolvePublicResourceUrlPath("/myapp/myservlet/index"));
|
||||
}
|
||||
|
||||
|
||||
private String resolvePublicResourceUrlPath(String path) {
|
||||
return this.servlet.wrappedResponse.encodeURL(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user