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

Spring Cloud 2021.0.0, Spring Boot 2.6.x - retrieving files (.json, .yl, .properties) fails in case a label is deifined in the url #2021

Closed
urferr opened this issue Dec 23, 2021 · 2 comments · Fixed by #2031

Comments

@urferr
Copy link

urferr commented Dec 23, 2021

To provide configuration properties for legacy apps we have to retrieve the configuration by file using one of the paths

  • /{label}/{application}-{profile}.yml
  • /{label}/{application}-{profile}.json
  • /{label}/{application}-{profile}.properties

unfortunately these path are not working anymore. Instead of being routed to the corresponding endpoint in the class org.springframework.cloud.config.server.environment.EnvironmentController annotated with

  • @GetMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" })
  • @GetMapping("/{label}/{name}-{profiles}.json")
  • @GetMapping("/{label}/{name}-{profiles}.properties")

they are all routed to the method annoteted with:
@GetMapping(path = "/{name}/{profiles:.[^-].}", produces = MediaType.APPLICATION_JSON_VALUE)
which is completely wrong.

I then tried to find out what goes wrong but i stuck in the method org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(String, HttpServletRequest) and there on the lines
Comparator comparator = new MatchComparator(getMappingComparator(request));
matches.sort(comparator);
bestMatch = matches.get(0);

the sorted result is different between Spring Cloud 2021.0.0, Spring Boot 2.6.x where its wring and Spring Cloud 2020.0.4, Spring Boot 2.5.8 where it was working and therefore the variable bestMatch contains the wrong path.

@ryanjbaxter
Copy link
Contributor

Sounds like it might be a duplicate of #2020?

@hpoettker
Copy link
Contributor

I think the old behavior should return if the property spring.mvc.pathmatch.matching-strategy: ant_path_matcher is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants