Skip to content

Commit ea3ba62

Browse files
committed
Correct Servlet Path JavaDoc
Initially PathPatternRequestMatcher was designed to match relative to the servlet path. However, this was changed to be relative to the context path. This commit updates the documentation and removes references to the servlet path other than in the context of setting a basePath to remove boilerplate. Issue gh-16430
1 parent 8fb8e26 commit ea3ba62

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

web/src/main/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcher.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
* (that is, it should exclude any context path).
3939
*
4040
* <p>
41-
* You can provide the servlet path in {@link PathPatternRequestMatcher#servletPath} and
42-
* reuse for multiple matchers.
41+
* You can provide the servlet path in {@link PathPatternRequestMatcher.Builder#basePath}
42+
* and reuse for multiple matchers.
4343
*
4444
* <p>
4545
* Note that the {@link org.springframework.web.servlet.HandlerMapping} that contains the
@@ -55,14 +55,12 @@ public final class PathPatternRequestMatcher implements RequestMatcher {
5555

5656
private final PathPattern pattern;
5757

58-
private RequestMatcher servletPath = AnyRequestMatcher.INSTANCE;
59-
6058
private RequestMatcher method = AnyRequestMatcher.INSTANCE;
6159

6260
/**
6361
* Creates a {@link PathPatternRequestMatcher} that uses the provided {@code pattern}.
6462
* <p>
65-
* The {@code pattern} should be relative to the servlet path
63+
* The {@code pattern} should be relative to the context path
6664
* </p>
6765
* @param pattern the pattern used to match
6866
*/
@@ -102,9 +100,6 @@ public boolean matches(HttpServletRequest request) {
102100
*/
103101
@Override
104102
public MatchResult matcher(HttpServletRequest request) {
105-
if (!this.servletPath.matches(request)) {
106-
return MatchResult.notMatch();
107-
}
108103
if (!this.method.matches(request)) {
109104
return MatchResult.notMatch();
110105
}
@@ -232,8 +227,9 @@ public Builder basePath(String basePath) {
232227
* also be followed by {@code /**} to signify all URIs under a given path.
233228
*
234229
* <p>
235-
* These must be specified relative to any servlet path prefix (meaning you should
236-
* exclude the context path and any servlet path prefix in stating your pattern).
230+
* These must be specified relative to any context path prefix. A
231+
* {@link #basePath} may be specified to reuse a common prefix, for example a
232+
* servlet path.
237233
*
238234
* <p>
239235
* The following are valid patterns and their meaning
@@ -266,8 +262,9 @@ public PathPatternRequestMatcher matcher(String path) {
266262
* also be followed by {@code /**} to signify all URIs under a given path.
267263
*
268264
* <p>
269-
* These must be specified relative to any servlet path prefix (meaning you should
270-
* exclude the context path and any servlet path prefix in stating your pattern).
265+
* These must be specified relative to any context path prefix. A
266+
* {@link #basePath} may be specified to reuse a common prefix, for example a
267+
* servlet path.
271268
*
272269
* <p>
273270
* The following are valid patterns and their meaning

0 commit comments

Comments
 (0)