Skip to content

PathPattern#combine throws StringIndexOutOfBoundsException #34986

Closed
@stefan-hasse

Description

@stefan-hasse

Situation
I've had the situation that a @Controller was defined with @RequestMapping("/*") to manage all request for that Dispatcher (that already defined urlPatterns="/main/something/*" to distinguish from other dispatcher).
Now, when the Dispatcher was initializing it was throwing StringIndexOutOfBoundsException for a method in that Controller with a @GetMapping(value = "/x/{val}") mapping defined.

*Root cause
I could drill this down to PathPattern:combine ... also reproducible by adding this case to spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java:combine

assertThat(pathMatcher.combine("/*", "/x/y")).isEqualTo("/x/y");

Workaround
Currently I've solved it by defining the @Controller with a @RequestMapping(/**) for matching multiple path segments (as I assume it's intended).

Enhancement
I am unsure whether it's

  • an enhancement request for a better exception OR
  • a bug in combine when instead of endsWithSeparatorWildcard it's equal to the wildcard

:)

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