question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using Spring MVC, unlike other endpoints, controller and REST controller endpoints use Ant path matching

See original GitHub issue

When we create WebMvcEndpointHandlerMapping we use the path pattern parser from the MVC auto-configuration:

https://github.com/spring-projects/spring-boot/blob/17bdc526f6af27478f45a828017e28c402c04e95/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java#L86-L88

However, when we create ControllerEndpointHandlerMapping, we don’t pass in a path pattern parser:

https://github.com/spring-projects/spring-boot/blob/17bdc526f6af27478f45a828017e28c402c04e95/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java#L116-L117

As a result, the default Ant-based path matching will be used. This feels inconsistent. However, there’s a risk that changing it will break users controller and rest controller endpoints if they have implementations that rely on some capabilities of the Ant-based matching that the path pattern parser doesn’t support. We may decide that we can’t do anything about this until 3.0.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Jul 14, 2022

It’s #31700.

1reaction
wilkinsonacommented, Jul 13, 2022

That doesn’t appear to be related to this issue which is specifically about request matching, not handler mapping beans. Please follow up on Stack Overflow or Gitter, but I think you’ll have to try to change PSTraceFilterAutoConfiguration. You cannot assume that there will only be a single RequestMappingHandlerMapping bean in the context. Spring MVC supports any number of them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

URL Matching with PathPattern in Spring MVC
In Spring applications AntPathMatcher is used to identify classpath, file system, remote, and other resources in Spring configuration. It has ...
Read more >
Spring MVC URL Matching Improvements - Baeldung
Spring 5 brought a new PathPatternParser for parsing URI template patterns. This is an alternative to the previously used AntPathMatcher.
Read more >
Spring MVC - URI Patterns - LogicBig
In this tutorial we will learn how many different kind of URI patterns can be used with ... Spring uses AntPathMatcher for pattern...
Read more >
Difference between antMatcher and mvcMatcher
mvcMatcher(String mvcPattern) - Allows configuring the HttpSecurity to only be invoked when matching the provided Spring MVC pattern. Generally ...
Read more >
Using the Spring @RequestMapping Annotation
@RequestMapping annotation is when used to map Spring MVC controller methods. Request Mapping Basics. In Spring MVC applications, the.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found