Remove warning about empty @RequestMapping path
See gh-22543
This commit is contained in:
@@ -41,14 +41,12 @@ import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsUtils;
|
||||
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
|
||||
@@ -415,12 +413,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
@Nullable
|
||||
protected abstract T getMappingForMethod(Method method, Class<?> handlerType);
|
||||
|
||||
/**
|
||||
* Extract and return the URL path patterns contained in the supplied mapping.
|
||||
* @since 5.2
|
||||
*/
|
||||
protected abstract Set<PathPattern> getMappingPathPatterns(T mapping);
|
||||
|
||||
/**
|
||||
* Check if a mapping matches the current request and return a (potentially
|
||||
* new) mapping with conditions relevant to the current request.
|
||||
@@ -507,16 +499,6 @@ 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()
|
||||
.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 \"**\".",
|
||||
handlerMethod, handlerMethod.getBean()));
|
||||
}
|
||||
|
||||
// Assert that the supplied mapping is unique.
|
||||
HandlerMethod existingHandlerMethod = this.mappingLookup.get(mapping);
|
||||
if (existingHandlerMethod != null && !existingHandlerMethod.equals(handlerMethod)) {
|
||||
|
||||
@@ -68,15 +68,6 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the URL path patterns associated with the supplied {@link RequestMappingInfo}.
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
protected Set<PathPattern> getMappingPathPatterns(RequestMappingInfo info) {
|
||||
return info.getPatternsCondition().getPatterns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given RequestMappingInfo matches the current request and
|
||||
* return a (potentially new) instance with conditions that match the
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package org.springframework.web.reactive.result.method;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
@@ -37,10 +35,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractHandlerMethodMapping}.
|
||||
@@ -158,11 +153,6 @@ public class HandlerMethodMappingTests {
|
||||
return methodName.startsWith("handler") ? methodName : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<PathPattern> getMappingPathPatterns(String mapping) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMatchingMapping(String pattern, ServerWebExchange exchange) {
|
||||
PathContainer lookupPath = exchange.getRequest().getPath().pathWithinApplication();
|
||||
|
||||
Reference in New Issue
Block a user