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

#24877 still occurring when trying to read RequestMappingInfo directly #29624

Closed
orubel opened this issue Feb 2, 2022 · 3 comments
Closed

#24877 still occurring when trying to read RequestMappingInfo directly #29624

orubel opened this issue Feb 2, 2022 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@orubel
Copy link

orubel commented Feb 2, 2022

I have a method that is reading the mapping info in order to work with/validate api connectors

    protected String getHandlerMappingInfo(HttpServletRequest request){
        RequestMappingHandlerMapping mapping = this.ctx.getBean(RequestMappingHandlerMapping.class);
        RequestMappingInfo requestMappingInfo = mapping.getHandlerMethods().entrySet().stream().filter(){ entry ->
                    println(entry.getKey())
                    if(entry?.getKey() != "{ [/error]}"){
                        entry?.getKey()?.getMatchingCondition(request) != null
                    }
                }.findFirst().map(){ entry ->
                    entry.getKey()
                }.orElse(null);
        return requestMappingInfo.toString()
    }

This throws an identical error to #24877

09:45:50.595 [http-nio-8080-exec-1] INFO  o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
09:45:50.596 [http-nio-8080-exec-1] INFO  o.s.web.servlet.DispatcherServlet - Completed initialization in 1 ms
{GET [/*/vehicle/vehiclesByManufacturer** || /*/vehicle/vehiclesByManufacturer/**]}
java.lang.IllegalArgumentException: Expected parsed RequestPath in request attribute "org.springframework.web.util.ServletRequestPathUtils.PATH".
	at org.springframework.util.Assert.notNull(Assert.java:201)
	at org.springframework.web.util.ServletRequestPathUtils.getParsedRequestPath(ServletRequestPathUtils.java:77)
	at org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition.getMatchingCondition(PathPatternsRequestCondition.java:192)
	at org.springframework.web.servlet.mvc.method.RequestMappingInfo.getMatchingCondition(RequestMappingInfo.java:399)
	at org.springframework.web.servlet.mvc.method.RequestMappingInfo.getMatchingCondition(RequestMappingInfo.java:66)
...

I may be mistaken but I don't think this is completely fixed for all possible paths. (It also threw an error when path was "{ [/error]}" as well)

The path you see "{GET [//vehicle/vehiclesByManufacturer** || //vehicle/vehiclesByManufacturer/**]}" is represented in the controller as
@RequestMapping(value = ["/vehiclesByManufacturer**","/vehiclesByManufacturer/**"], method = RequestMethod.GET)

This allows for multiple URI's to be handled by one endpoint or for an endpoint to have an ALIAS and is covered in documentation.

I believe this may not be being considered for the pathing as it is throwing an error???

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 2, 2022
@bclozel
Copy link
Member

bclozel commented Feb 2, 2022

Where is that code written and called?
If this is done outside of the Spring Boot or Spring Framework codebases (for example, a custom filter), this might be a duplicate of #28874.

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Feb 2, 2022
@orubel
Copy link
Author

orubel commented Feb 2, 2022

No it is in springboot. Its in a filter: https://github.com/orubel/spring-boot-starter-beapi/blob/main/beapi-spring-boot-autoconfigure/src/main/groovy/io/beapi/api/filter/RequestInitializationFilter.groovy

Code is here: https://github.com/orubel/spring-boot-starter-beapi

I also added note up above; I believe this might be related to multiple @RequestMapping values

The code is a multimodule starter/autoconfig with demo project

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 2, 2022
@bclozel
Copy link
Member

bclozel commented Feb 2, 2022

That's definitely a duplicate of #28874.
You custom filter is not initializing the request path. Note the comments in that linked issue saying that this is not an approach that the team supports.
Thanks!

@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Feb 2, 2022
@bclozel bclozel closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants