From 1966ff3ce8dcda4242dcc65300ddf014c08aef30 Mon Sep 17 00:00:00 2001 From: Josh Cummings <3627351+jzheaux@users.noreply.github.com> Date: Fri, 21 Mar 2025 11:26:59 -0600 Subject: [PATCH] Parse RequestPath when cache is empty Closes gh-16771 --- .../servlet/util/matcher/PathPatternRequestMatcher.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/src/main/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcher.java b/web/src/main/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcher.java index 5d3d434523..c763850163 100644 --- a/web/src/main/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcher.java +++ b/web/src/main/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcher.java @@ -127,12 +127,15 @@ public final class PathPatternRequestMatcher implements RequestMatcher { } private RequestPath getRequestPath(HttpServletRequest request) { + RequestPath path; if (ServletRequestPathUtils.hasParsedRequestPath(request)) { - return ServletRequestPathUtils.getParsedRequestPath(request); + path = ServletRequestPathUtils.getParsedRequestPath(request); } else { - return ServletRequestPathUtils.parseAndCache(request); + path = ServletRequestPathUtils.parseAndCache(request); + ServletRequestPathUtils.clearParsedRequestPath(request); } + return path; } /**