-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
Description
Affected version: 5.1.8
I am trying to disable suffix pattern matching so that PathVariables containing dots will not be truncated. The documented solution for this problem
webMvcConfigurer.setUseSuffixPatternMatch(false)
works fine, but it breaks if I also try to add a path prefix
webMvcConfigurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class))
The problem is in PatternsRequestCondition.combine(PatternRequestCondition other) at line 179. Here the useSuffixPatternMatch on my url is ignored in favor of the value on the '/api' Condition create at RequestMappingHandlerMapping.228
RequestMappingHandlerMapping.java
@Override
@Nullable
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = createRequestMappingInfo(method);
if (info != null) {
RequestMappingInfo typeInfo = createRequestMappingInfo(handlerType);
if (typeInfo != null) {
info = typeInfo.combine(info);
}
String prefix = getPathPrefix(handlerType);
if (prefix != null) {
// PROBLEM HERE
info = RequestMappingInfo.paths(prefix).build().combine(info);**
}
}
return info;
}
PatternsRequestCondition.java
@Override
public PatternsRequestCondition combine(PatternsRequestCondition other) {
Set<String> result = new LinkedHashSet<>();
if (!this.patterns.isEmpty() && !other.patterns.isEmpty()) {
for (String pattern1 : this.patterns) {
for (String pattern2 : other.patterns) {
result.add(this.pathMatcher.combine(pattern1, pattern2));
}
}
}
else if (!this.patterns.isEmpty()) {
result.addAll(this.patterns);
}
else if (!other.patterns.isEmpty()) {
result.addAll(other.patterns);
}
else {
result.add("");
}
// PROBLEM HERE
return new PatternsRequestCondition(result, this.pathHelper, this.pathMatcher,
this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions);
}
`
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug