Skip to content

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

Closed
@rstoyanchev

Description

@rstoyanchev

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.

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