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
This commit is contained in:
parent
dacda5859a
commit
510c0c5ef7
|
|
@ -48,6 +48,7 @@ import org.springframework.web.method.HandlerMethod;
|
|||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.handler.AbstractHandlerMapping;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link HandlerMapping} implementations that define
|
||||
|
|
@ -418,7 +419,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
|||
* Extract and return the URL paths contained in the supplied mapping.
|
||||
* @since 5.2
|
||||
*/
|
||||
protected abstract Set<String> getMappingPathPatterns(T mapping);
|
||||
protected abstract Set<PathPattern> getMappingPathPatterns(T mapping);
|
||||
|
||||
/**
|
||||
* Check if a mapping matches the current request and return a (potentially
|
||||
|
|
@ -508,7 +509,8 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
|||
private void validateMethodMapping(HandlerMethod handlerMethod, T mapping) {
|
||||
// Log a warning if the supplied mapping maps the supplied HandlerMethod
|
||||
// only to empty paths.
|
||||
if (logger.isWarnEnabled() && getMappingPathPatterns(mapping).stream().noneMatch(StringUtils::hasText)) {
|
||||
if (logger.isWarnEnabled() && getMappingPathPatterns(mapping).stream()
|
||||
.map(PathPattern::getPatternString).noneMatch(StringUtils::hasText)) {
|
||||
logger.warn(String.format(
|
||||
"Handler method '%s' in bean '%s' is not mapped to an explicit path. " +
|
||||
"If you wish to map to all paths, please map explicitly to \"/**\" or \"**\".",
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
|||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> getMappingPathPatterns(RequestMappingInfo info) {
|
||||
return info.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString).collect(Collectors.toSet());
|
||||
protected Set<PathPattern> getMappingPathPatterns(RequestMappingInfo info) {
|
||||
return info.getPatternsCondition().getPatterns();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public class HandlerMethodMappingTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> getMappingPathPatterns(String mapping) {
|
||||
protected Set<PathPattern> getMappingPathPatterns(String mapping) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -480,8 +479,8 @@ public class RequestMappingInfoHandlerMappingTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> getMappingPathPatterns(RequestMappingInfo info) {
|
||||
return info.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString).collect(Collectors.toSet());
|
||||
protected Set<PathPattern> getMappingPathPatterns(RequestMappingInfo info) {
|
||||
return info.getPatternsCondition().getPatterns();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue