HandlerMappingIntrospector ensures initialized RequestPath

Closes gh-26814
This commit is contained in:
Rossen Stoyanchev
2021-04-16 19:55:52 +01:00
parent 0f31830ae2
commit 69bbdce826
4 changed files with 118 additions and 45 deletions

View File

@@ -127,16 +127,11 @@ public class HandlerMappingIntrospectorTests {
context.refresh();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/path/123");
// Initialize the RequestPath. At runtime, ServletRequestPathFilter is expected to do that.
if (usePathPatterns) {
ServletRequestPathUtils.parseAndCache(request);
}
MatchableHandlerMapping mapping = initIntrospector(context).getMatchableHandlerMapping(request);
assertThat(mapping).isNotNull();
assertThat(request.getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE)).as("Attribute changes not ignored").isNull();
assertThat(request.getAttribute(ServletRequestPathUtils.PATH_ATTRIBUTE)).as("Parsed path not cleaned").isNull();
assertThat(mapping.match(request, "/p*/*")).isNotNull();
assertThat(mapping.match(request, "/b*/*")).isNull();