-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Reconsider AntPathRequestMatcher matching logic #9301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @evgeniycheban! I've left some feedback inline.
@@ -159,9 +160,12 @@ public boolean matches(HttpServletRequest request) { | |||
|
|||
@Override | |||
public MatchResult matcher(HttpServletRequest request) { | |||
if (this.matcher == null || !matches(request)) { | |||
if (!matches(request)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this.matcher == null
should be the first check in order to avoid potential NPEs in matches(HttpServletRequest)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The matcher
will only be null if the pattern
is MATCH_ALL
, and we need to check the HttpMethod
first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Is the null check necessary, then? It seems like it could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check is necessary since matcher
is used to extract variables, for the MATCH_ALL
pattern there will be an empty Map
of variables.
Closes gh-9285