Skip to content

Commit 4706ebc

Browse files
committed
Minor refactoring in UrlHandlerFilter
See gh-33565
1 parent 2090ece commit 4706ebc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

spring-web/src/main/java/org/springframework/web/filter/UrlHandlerFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
9595
path = ServletRequestPathUtils.parseAndCache(request);
9696
}
9797
for (Map.Entry<Handler, List<PathPattern>> entry : this.handlers.entrySet()) {
98-
if (!entry.getKey().canHandle(request, path)) {
98+
if (!entry.getKey().supports(request, path)) {
9999
continue;
100100
}
101101
for (PathPattern pattern : entry.getValue()) {
@@ -248,7 +248,7 @@ private interface Handler {
248248
/**
249249
* Whether the handler handles the given request.
250250
*/
251-
boolean canHandle(HttpServletRequest request, RequestPath path);
251+
boolean supports(HttpServletRequest request, RequestPath path);
252252

253253
/**
254254
* Handle the request, possibly delegating to the rest of the filter chain.
@@ -277,7 +277,7 @@ protected AbstractTrailingSlashHandler(@Nullable Consumer<HttpServletRequest> in
277277
}
278278

279279
@Override
280-
public boolean canHandle(HttpServletRequest request, RequestPath path) {
280+
public boolean supports(HttpServletRequest request, RequestPath path) {
281281
List<PathContainer.Element> elements = path.pathWithinApplication().elements();
282282
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));
283283
}

spring-web/src/main/java/org/springframework/web/filter/reactive/UrlHandlerFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private UrlHandlerFilter(MultiValueMap<Handler, PathPattern> handlers) {
7878
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
7979
RequestPath path = exchange.getRequest().getPath();
8080
for (Map.Entry<Handler, List<PathPattern>> entry : this.handlers.entrySet()) {
81-
if (!entry.getKey().canHandle(exchange)) {
81+
if (!entry.getKey().supports(exchange)) {
8282
continue;
8383
}
8484
for (PathPattern pattern : entry.getValue()) {
@@ -223,7 +223,7 @@ private interface Handler {
223223
/**
224224
* Whether the handler handles the given request.
225225
*/
226-
boolean canHandle(ServerWebExchange exchange);
226+
boolean supports(ServerWebExchange exchange);
227227

228228
/**
229229
* Handle the request, possibly delegating to the rest of the filter chain.
@@ -252,7 +252,7 @@ protected AbstractTrailingSlashHandler(@Nullable List<Function<ServerHttpRequest
252252
}
253253

254254
@Override
255-
public boolean canHandle(ServerWebExchange exchange) {
255+
public boolean supports(ServerWebExchange exchange) {
256256
ServerHttpRequest request = exchange.getRequest();
257257
List<PathContainer.Element> elements = request.getPath().pathWithinApplication().elements();
258258
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));

0 commit comments

Comments
 (0)