Skip to content

@RequestMapping method resolution issue with duplicate paths [SPR-5069] #9744

@spring-projects-issues

Description

@spring-projects-issues

William Butler opened SPR-5069 and commented

This bug is related to the fix for #9228.

There is still an issue related to the following method (in AnnotationMethodHandlerAdapter.java):

[CODE]
private boolean isBetterPathMatch(String mappedPath, String mappedPathToCompare, String lookupPath) {
return (mappedPath != null && (mappedPathToCompare == null ||
mappedPath.equals(lookupPath) || mappedPathToCompare.length() < mappedPath.length()));
}
[/CODE]

If multiple methods are annotated with the same path value, one can be considered "better" than another based on the fact that the mappedPath equals lookupPath. There is no check to see if the mappedPathToCompare is also equal to the lookupPath. The code should probably be changed to something like:

[CODE]
private boolean isBetterPathMatch(String mappedPath, String mappedPathToCompare, String lookupPath) {
return (mappedPath != null && (mappedPathToCompare == null ||
mappedPath.equals(lookupPath) && !mappedPathToCompare.equals(lookupPath) || mappedPathToCompare.length() < mappedPath.length()));
}
[/CODE]


Affects: 2.5.3, 2.5.4, 2.5.5

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions