Skip to content
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

Programmatic registration of RequestMappingInfo leads to "IllegalArgumentException: Expected lookup path" #31662

Closed
rstoyanchev opened this issue Nov 23, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Nov 23, 2023

The example shown in the Explicit Registrations section of the reference docs fails with:

2023-11-17T13:01:02.412Z ERROR 1320501 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalArgumentException: Expected lookupPath in request attribute "org.springframework.web.util.UrlPathHelper.PATH".] with root cause

java.lang.IllegalArgumentException: Expected lookupPath in request attribute "org.springframework.web.util.UrlPathHelper.PATH".
        at org.springframework.util.Assert.notNull(Assert.java:222) ~[spring-core-6.0.13.jar:6.0.13]
        at org.springframework.web.util.UrlPathHelper.getResolvedLookupPath(UrlPathHelper.java:208) ~[spring-web-6.0.13.jar:6.0.13]
        at org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getMatchingCondition(PatternsRequestCondition.java:280) ~[spring-webmvc-6.0.13.jar:6.0.13]
        at org.springframework.web.servlet.mvc.method.RequestMappingInfo.getMatchingCondition(RequestMappingInfo.java:414) ~[spring-webmvc-6.0.13.jar:6.0.13]

This is because RequestMappingInfo.Builder defaults to AntPathMatcher while (as of 6.0) RequestMappingHandlerMapping defaults to PathPatternParser. We need to align the defaults between the two, but also provide a way to create a RequestMappingInfo that's initialized from the internal configuration of RequestMappingHandlerMapping with additional customizations then layered on top.

@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug labels Nov 23, 2023
@rstoyanchev rstoyanchev added this to the 6.1.2 milestone Nov 23, 2023
@rstoyanchev rstoyanchev self-assigned this Nov 23, 2023
rstoyanchev added a commit that referenced this issue Dec 13, 2023
Refining the change from 4370030 so that
we consistently pick a PathPatternParser (a) if it is provided, and (b)
if both PathPatternParser and PathMatcher are not provided. Also applying
the same in the mutate builder.

See gh-31662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant