From 8c03d55905a437a5c13b8b1bb44b15ac743a7811 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 10 Jan 2025 18:49:57 +0000 Subject: [PATCH] Deprecate HandlerMappingIntrospector Closes gh-34019 --- .../web/servlet/config/MvcNamespaceUtils.java | 3 ++- .../config/annotation/WebMvcConfigurationSupport.java | 3 ++- .../web/servlet/function/support/RouterFunctionMapping.java | 3 ++- .../web/servlet/handler/AbstractUrlHandlerMapping.java | 3 ++- .../web/servlet/handler/HandlerMappingIntrospector.java | 5 +++++ .../web/servlet/handler/MatchableHandlerMapping.java | 6 ++++-- .../servlet/handler/PathPatternMatchableHandlerMapping.java | 5 ++++- .../web/servlet/handler/RequestMatchResult.java | 3 +++ .../mvc/method/annotation/RequestMappingHandlerMapping.java | 3 ++- .../servlet/handler/HandlerMappingIntrospectorTests.java | 3 ++- 10 files changed, 28 insertions(+), 9 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java index b21c1b801f..bef6e92fcc 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -280,6 +280,7 @@ public abstract class MvcNamespaceUtils { * Registers an {@link HandlerMappingIntrospector} under a well-known name * unless already registered. */ + @SuppressWarnings("removal") private static void registerHandlerMappingIntrospector(ParserContext context, @Nullable Object source) { if (!context.getRegistry().containsBeanDefinition(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) { RootBeanDefinition beanDef = new RootBeanDefinition(HandlerMappingIntrospector.class); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 387ce6c405..89a9fa1fec 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -1172,6 +1172,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv protected void addCorsMappings(CorsRegistry registry) { } + @SuppressWarnings("removal") @Bean @Lazy public HandlerMappingIntrospector mvcHandlerMappingIntrospector() { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java index 6a67ff7e11..b0ad2a1d68 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -55,6 +55,7 @@ import org.springframework.web.util.pattern.PathPatternParser; * @author Brian Clozel * @since 5.2 */ +@SuppressWarnings("removal") public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean, MatchableHandlerMapping { private @Nullable RouterFunction routerFunction; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java index b2572678a1..9fc500c959 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -61,6 +61,7 @@ import org.springframework.web.util.pattern.PathPatternParser; * @author Arjen Poutsma * @since 16.04.2003 */ +@SuppressWarnings("removal") public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping implements MatchableHandlerMapping { private @Nullable Object rootHandler; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java index b982a84b4b..c3f8426e45 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java @@ -90,7 +90,12 @@ import org.springframework.web.util.pattern.PathPatternParser; * * @author Rossen Stoyanchev * @since 4.3.1 + * @deprecated in favor of using just {@link PathPatternParser}; when + * {@link #allHandlerMappingsUsePathPatternParser} returns true, it is sufficient + * to use that to align with handler mappings. */ +@SuppressWarnings("removal") +@Deprecated(since = "7.0", forRemoval = true) public class HandlerMappingIntrospector implements CorsConfigurationSource, PreFlightRequestHandler, ApplicationContextAware, InitializingBean { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MatchableHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MatchableHandlerMapping.java index 2b8f24e9e2..33dab0e22e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MatchableHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MatchableHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -31,8 +31,9 @@ import org.springframework.web.util.pattern.PathPatternParser; * * @author Rossen Stoyanchev * @since 4.3.1 - * @see HandlerMappingIntrospector + * @deprecated together with {@link HandlerMappingIntrospector} without a replacement. */ +@Deprecated(since = "7.0", forRemoval = true) public interface MatchableHandlerMapping extends HandlerMapping { /** @@ -55,6 +56,7 @@ public interface MatchableHandlerMapping extends HandlerMapping { * for use at runtime in web modules in favor of parsed patterns with * {@link PathPatternParser}. */ + @SuppressWarnings("removal") @Deprecated(since = "7.0", forRemoval = true) @Nullable RequestMatchResult match(HttpServletRequest request, String pattern); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/PathPatternMatchableHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/PathPatternMatchableHandlerMapping.java index 8537daf75c..12aff02698 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/PathPatternMatchableHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/PathPatternMatchableHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -36,7 +36,10 @@ import org.springframework.web.util.pattern.PathPatternParser; * * @author Rossen Stoyanchev * @since 5.3 + * @deprecated together with {@link HandlerMappingIntrospector} without a replacement. */ +@SuppressWarnings("removal") +@Deprecated(since = "7.0", forRemoval = true) class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping { private static final int MAX_PATTERNS = 1024; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java index 4fcafdb64f..90a82ade4f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/RequestMatchResult.java @@ -34,7 +34,10 @@ import org.springframework.web.util.pattern.PathPatternParser; * * @author Rossen Stoyanchev * @since 4.3.1 + * @deprecated together with {@link HandlerMappingIntrospector} without a replacement. */ +@SuppressWarnings("removal") +@Deprecated(since = "7.0", forRemoval = true) public class RequestMatchResult { private final @Nullable PathPattern pathPattern; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 57917a3466..ddb731f20b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -71,6 +71,7 @@ import org.springframework.web.util.UrlPathHelper; * @author Olga Maciaszek-Sharma * @since 3.1 */ +@SuppressWarnings("removal") public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMapping implements MatchableHandlerMapping, EmbeddedValueResolverAware { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java index 9c334fcc1f..f0a19afbc9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -73,6 +73,7 @@ import static org.springframework.web.servlet.HandlerMapping.BEST_MATCHING_PATTE * @author Rossen Stoyanchev * @since 4.3.1 */ +@SuppressWarnings("removal") class HandlerMappingIntrospectorTests { @Test