Skip to content

Commit 510c0c5

Browse files
committed
Return Set<PathPattern> from AbstractHandlerMethodMapping.getMappingPathPatterns
This commit revises the signature of getMappingPathPatterns() in AbstractHandlerMethodMapping to return a set of PathPatterns instead of a set of Strings. See gh-22543
1 parent dacda58 commit 510c0c5

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.springframework.web.reactive.HandlerMapping;
4949
import org.springframework.web.reactive.handler.AbstractHandlerMapping;
5050
import org.springframework.web.server.ServerWebExchange;
51+
import org.springframework.web.util.pattern.PathPattern;
5152

5253
/**
5354
* Abstract base class for {@link HandlerMapping} implementations that define
@@ -418,7 +419,7 @@ protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchan
418419
* Extract and return the URL paths contained in the supplied mapping.
419420
* @since 5.2
420421
*/
421-
protected abstract Set<String> getMappingPathPatterns(T mapping);
422+
protected abstract Set<PathPattern> getMappingPathPatterns(T mapping);
422423

423424
/**
424425
* Check if a mapping matches the current request and return a (potentially
@@ -508,7 +509,8 @@ public void register(T mapping, Object handler, Method method) {
508509
private void validateMethodMapping(HandlerMethod handlerMethod, T mapping) {
509510
// Log a warning if the supplied mapping maps the supplied HandlerMethod
510511
// only to empty paths.
511-
if (logger.isWarnEnabled() && getMappingPathPatterns(mapping).stream().noneMatch(StringUtils::hasText)) {
512+
if (logger.isWarnEnabled() && getMappingPathPatterns(mapping).stream()
513+
.map(PathPattern::getPatternString).noneMatch(StringUtils::hasText)) {
512514
logger.warn(String.format(
513515
"Handler method '%s' in bean '%s' is not mapped to an explicit path. " +
514516
"If you wish to map to all paths, please map explicitly to \"/**\" or \"**\".",

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handler
170170
* @since 5.2
171171
*/
172172
@Override
173-
protected Set<String> getMappingPathPatterns(RequestMappingInfo info) {
174-
return info.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString).collect(Collectors.toSet());
173+
protected Set<PathPattern> getMappingPathPatterns(RequestMappingInfo info) {
174+
return info.getPatternsCondition().getPatterns();
175175
}
176176

177177
/**

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ protected String getMappingForMethod(Method method, Class<?> handlerType) {
159159
}
160160

161161
@Override
162-
protected Set<String> getMappingPathPatterns(String mapping) {
162+
protected Set<PathPattern> getMappingPathPatterns(String mapping) {
163163
return Collections.emptySet();
164164
}
165165

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.Map;
2727
import java.util.Set;
2828
import java.util.function.Consumer;
29-
import java.util.stream.Collectors;
3029

3130
import org.junit.Before;
3231
import org.junit.Test;
@@ -480,8 +479,8 @@ protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handler
480479
}
481480

482481
@Override
483-
protected Set<String> getMappingPathPatterns(RequestMappingInfo info) {
484-
return info.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString).collect(Collectors.toSet());
482+
protected Set<PathPattern> getMappingPathPatterns(RequestMappingInfo info) {
483+
return info.getPatternsCondition().getPatterns();
485484
}
486485
}
487486

0 commit comments

Comments
 (0)