From 85f05023c63801af514979889edf1783a0f179a9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 9 Apr 2019 10:56:27 +0200 Subject: [PATCH] Pull WebFlux getMappingPathPatterns() implementation up in the hierarchy This commit moves the WebFlux getMappingPathPatterns() implementation from RequestMappingHandlerMapping to RequestMappingInfoHandlerMapping so that subclasses of the latter no longer need to re-implement the method. See gh-22543 --- .../method/RequestMappingInfoHandlerMapping.java | 12 +++++++++++- .../annotation/RequestMappingHandlerMapping.java | 11 ----------- .../RequestMappingInfoHandlerMappingTests.java | 5 ----- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java index b2c42fff9e..66ca1c8533 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ import org.springframework.web.util.pattern.PathPattern; * the mapping between a request and a handler method. * * @author Rossen Stoyanchev + * @author Sam Brannen * @since 5.0 */ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMethodMapping { @@ -67,6 +68,15 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe } + /** + * Get the URL path patterns associated with the supplied {@link RequestMappingInfo}. + * @since 5.2 + */ + @Override + protected Set 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 diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java index 8938bc95e8..5035390f99 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java @@ -21,7 +21,6 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import org.springframework.context.EmbeddedValueResolverAware; @@ -42,7 +41,6 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuild import org.springframework.web.reactive.result.condition.RequestCondition; import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; -import org.springframework.web.util.pattern.PathPattern; /** * An extension of {@link RequestMappingInfoHandlerMapping} that creates @@ -164,15 +162,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi return info; } - /** - * Get the URL path patterns associated with the supplied {@link RequestMappingInfo}. - * @since 5.2 - */ - @Override - protected Set getMappingPathPatterns(RequestMappingInfo info) { - return info.getPatternsCondition().getPatterns(); - } - /** * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)}, * supplying the appropriate custom {@link RequestCondition} depending on whether diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index 6b6f8decf7..b77d268d6b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -477,11 +477,6 @@ public class RequestMappingInfoHandlerMappingTests { return null; } } - - @Override - protected Set getMappingPathPatterns(RequestMappingInfo info) { - return info.getPatternsCondition().getPatterns(); - } } }