Minor refactoring in UrlHandlerFilter

See gh-33565
This commit is contained in:
rstoyanchev
2024-09-18 22:45:09 +01:00
parent 2090ece62a
commit 4706ebc81e
2 changed files with 6 additions and 6 deletions

View File

@@ -95,7 +95,7 @@ public final class UrlHandlerFilter extends OncePerRequestFilter {
path = ServletRequestPathUtils.parseAndCache(request);
}
for (Map.Entry<Handler, List<PathPattern>> entry : this.handlers.entrySet()) {
if (!entry.getKey().canHandle(request, path)) {
if (!entry.getKey().supports(request, path)) {
continue;
}
for (PathPattern pattern : entry.getValue()) {
@@ -248,7 +248,7 @@ public final class UrlHandlerFilter extends OncePerRequestFilter {
/**
* Whether the handler handles the given request.
*/
boolean canHandle(HttpServletRequest request, RequestPath path);
boolean supports(HttpServletRequest request, RequestPath path);
/**
* Handle the request, possibly delegating to the rest of the filter chain.
@@ -277,7 +277,7 @@ public final class UrlHandlerFilter extends OncePerRequestFilter {
}
@Override
public boolean canHandle(HttpServletRequest request, RequestPath path) {
public boolean supports(HttpServletRequest request, RequestPath path) {
List<PathContainer.Element> elements = path.pathWithinApplication().elements();
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));
}

View File

@@ -78,7 +78,7 @@ public final class UrlHandlerFilter implements WebFilter {
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
RequestPath path = exchange.getRequest().getPath();
for (Map.Entry<Handler, List<PathPattern>> entry : this.handlers.entrySet()) {
if (!entry.getKey().canHandle(exchange)) {
if (!entry.getKey().supports(exchange)) {
continue;
}
for (PathPattern pattern : entry.getValue()) {
@@ -223,7 +223,7 @@ public final class UrlHandlerFilter implements WebFilter {
/**
* Whether the handler handles the given request.
*/
boolean canHandle(ServerWebExchange exchange);
boolean supports(ServerWebExchange exchange);
/**
* Handle the request, possibly delegating to the rest of the filter chain.
@@ -252,7 +252,7 @@ public final class UrlHandlerFilter implements WebFilter {
}
@Override
public boolean canHandle(ServerWebExchange exchange) {
public boolean supports(ServerWebExchange exchange) {
ServerHttpRequest request = exchange.getRequest();
List<PathContainer.Element> elements = request.getPath().pathWithinApplication().elements();
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));