Skip to content

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

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

evgeniycheban
Copy link
Contributor

Closes gh-9285

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 21, 2020
Copy link
Contributor

@jzheaux jzheaux left a 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)) {
Copy link
Contributor

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).

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jzheaux jzheaux self-assigned this Jan 5, 2021
@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 5, 2021
@evgeniycheban evgeniycheban requested a review from jzheaux January 9, 2021 07:40
@jzheaux jzheaux merged commit 7748401 into spring-projects:master Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconsider AntPathRequestMatcher matching logic
3 participants