Deprecate use of PathMatcher and UrlPathHelper in web

Closes gh-34018
This commit is contained in:
rstoyanchev 2024-12-18 17:22:06 +00:00
parent 41a9db376d
commit 373763723e
56 changed files with 352 additions and 44 deletions

View File

@ -157,9 +157,7 @@ Kotlin::
---- ----
====== ======
Note that you need to enable the use of matrix variables. In the MVC Java configuration, Note that you need to enable the use of matrix variables. In the MVC XML namespace, you can set
you need to set a `UrlPathHelper` with `removeSemicolonContent=false` through
xref:web/webmvc/mvc-config/path-matching.adoc[Path Matching]. In the MVC XML namespace, you can set
`<mvc:annotation-driven enable-matrix-variables="true"/>`. `<mvc:annotation-driven enable-matrix-variables="true"/>`.

View File

@ -188,9 +188,9 @@ public class RouterFunctionMockMvcBuilder extends AbstractMockMvcBuilder<RouterF
} }
/** /**
* Enable URL path matching with parsed * Configure the parser to use for
* {@link org.springframework.web.util.pattern.PathPattern PathPatterns} * {@link org.springframework.web.util.pattern.PathPattern PathPatterns}.
* instead of String pattern matching with a {@link org.springframework.util.PathMatcher}. * <p>By default, this is a default instance of {@link PathPatternParser}.
* @param parser the parser to use * @param parser the parser to use
*/ */
public RouterFunctionMockMvcBuilder setPatternParser(@Nullable PathPatternParser parser) { public RouterFunctionMockMvcBuilder setPatternParser(@Nullable PathPatternParser parser) {

View File

@ -37,6 +37,7 @@ import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.format.support.FormattingConversionService; import org.springframework.format.support.FormattingConversionService;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.util.PathMatcher;
import org.springframework.util.PropertyPlaceholderHelper; import org.springframework.util.PropertyPlaceholderHelper;
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
@ -297,9 +298,9 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
} }
/** /**
* Enable URL path matching with parsed * Configure the parser to use for
* {@link org.springframework.web.util.pattern.PathPattern PathPatterns} * {@link org.springframework.web.util.pattern.PathPattern PathPatterns}.
* instead of String pattern matching with a {@link org.springframework.util.PathMatcher}. * <p>By default, this is a default instance of {@link PathPatternParser}.
* @param parser the parser to use * @param parser the parser to use
* @since 5.3 * @since 5.3
*/ */
@ -313,7 +314,11 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
* Set if ";" (semicolon) content should be stripped from the request URI. The value, * Set if ";" (semicolon) content should be stripped from the request URI. The value,
* if provided, is in turn set on * if provided, is in turn set on
* {@link org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)}. * {@link org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public StandaloneMockMvcBuilder setRemoveSemicolonContent(boolean removeSemicolonContent) { public StandaloneMockMvcBuilder setRemoveSemicolonContent(boolean removeSemicolonContent) {
this.removeSemicolonContent = removeSemicolonContent; this.removeSemicolonContent = removeSemicolonContent;
return this; return this;
@ -428,6 +433,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
/** Using the MVC Java configuration as the starting point for the "standalone" setup. */ /** Using the MVC Java configuration as the starting point for the "standalone" setup. */
private class StandaloneConfiguration extends WebMvcConfigurationSupport { private class StandaloneConfiguration extends WebMvcConfigurationSupport {
@SuppressWarnings("removal")
public RequestMappingHandlerMapping getHandlerMapping( public RequestMappingHandlerMapping getHandlerMapping(
FormattingConversionService mvcConversionService, FormattingConversionService mvcConversionService,
ResourceUrlProvider mvcResourceUrlProvider) { ResourceUrlProvider mvcResourceUrlProvider) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -105,6 +105,7 @@ public class EncodedUriTests {
@Component @Component
static class HandlerMappingConfigurer implements BeanPostProcessor, PriorityOrdered { static class HandlerMappingConfigurer implements BeanPostProcessor, PriorityOrdered {
@SuppressWarnings("removal")
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof RequestMappingHandlerMapping requestMappingHandlerMapping) { if (bean instanceof RequestMappingHandlerMapping requestMappingHandlerMapping) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -141,7 +141,11 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
* parsed {@code PathPatterns} are used instead. * parsed {@code PathPatterns} are used instead.
* For further details on that, see {@link #setAllowInitLookupPath(boolean)}. * For further details on that, see {@link #setAllowInitLookupPath(boolean)}.
* <p>By default this is {@link UrlPathHelper#defaultInstance}. * <p>By default this is {@link UrlPathHelper#defaultInstance}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); Assert.notNull(urlPathHelper, "UrlPathHelper must not be null");
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
@ -167,7 +171,11 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
* @param allowInitLookupPath whether to disable lazy initialization * @param allowInitLookupPath whether to disable lazy initialization
* and fail if not already resolved * and fail if not already resolved
* @since 5.3 * @since 5.3
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setAllowInitLookupPath(boolean allowInitLookupPath) { public void setAllowInitLookupPath(boolean allowInitLookupPath) {
this.allowInitLookupPath = allowInitLookupPath; this.allowInitLookupPath = allowInitLookupPath;
} }
@ -194,7 +202,11 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
* String pattern matching even when a * String pattern matching even when a
* {@link ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath} * {@link ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath}
* is available. * is available.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(PathMatcher pathMatcher) { public void setPathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
} }

View File

@ -71,6 +71,7 @@ class UrlBasedCorsConfigurationSourceTests {
.isThrownBy(() -> source.getCorsConfigurations().put("/**", new CorsConfiguration())); .isThrownBy(() -> source.getCorsConfigurations().put("/**", new CorsConfiguration()));
} }
@SuppressWarnings("removal")
@Test @Test
void allowInitLookupPath() { void allowInitLookupPath() {
CorsConfiguration config = new CorsConfiguration(); CorsConfiguration config = new CorsConfiguration();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,9 @@ import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.handler.MappedInterceptor; import org.springframework.web.servlet.handler.MappedInterceptor;
import org.springframework.web.util.ServletRequestPathUtils; import org.springframework.web.util.ServletRequestPathUtils;
import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPattern;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* Assists with the creation of a {@link MappedInterceptor}. * Assists with the creation of a {@link MappedInterceptor}.
@ -114,7 +116,11 @@ public class InterceptorRegistration {
* String pattern matching even when a * String pattern matching even when a
* {@link ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath} * {@link ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath}
* is available. * is available.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public InterceptorRegistration pathMatcher(PathMatcher pathMatcher) { public InterceptorRegistration pathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
return this; return this;
@ -140,6 +146,7 @@ public class InterceptorRegistration {
* Build the underlying interceptor. If URL patterns are provided, the returned * Build the underlying interceptor. If URL patterns are provided, the returned
* type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}. * type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}.
*/ */
@SuppressWarnings("removal")
protected Object getInterceptor() { protected Object getInterceptor() {
if (this.includePatterns == null && this.excludePatterns == null) { if (this.includePatterns == null && this.excludePatterns == null) {

View File

@ -65,12 +65,6 @@ public class PathMatchConfigurer {
* Set the {@link PathPatternParser} to parse {@link PathPattern patterns} * Set the {@link PathPatternParser} to parse {@link PathPattern patterns}
* with for URL path matching. Parsed patterns provide a more modern and * with for URL path matching. Parsed patterns provide a more modern and
* efficient alternative to String path matching via {@link AntPathMatcher}. * efficient alternative to String path matching via {@link AntPathMatcher}.
* <p><strong>Note:</strong> This property is mutually exclusive with the
* following other, {@code AntPathMatcher} related properties:
* <ul>
* <li>{@link #setUrlPathHelper(UrlPathHelper)}
* <li>{@link #setPathMatcher(PathMatcher)}
* </ul>
* <p>By default, as of 6.0, a {@link PathPatternParser} with default * <p>By default, as of 6.0, a {@link PathPatternParser} with default
* settings is used, which enables parsed {@link PathPattern patterns}. * settings is used, which enables parsed {@link PathPattern patterns}.
* Set this property to {@code null} to fall back on String path matching via * Set this property to {@code null} to fall back on String path matching via
@ -110,9 +104,13 @@ public class PathMatchConfigurer {
* {@link #setPatternParser(PathPatternParser)}. If set, it enables use of * {@link #setPatternParser(PathPatternParser)}. If set, it enables use of
* String path matching, unless a {@code PathPatternParser} is also * String path matching, unless a {@code PathPatternParser} is also
* explicitly set in which case this property is ignored. * explicitly set in which case this property is ignored.
* <p>By default this is an instance of {@link UrlPathHelper} with default * <p>By default, this is an instance of {@link UrlPathHelper} with default
* settings. * settings.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public PathMatchConfigurer setUrlPathHelper(UrlPathHelper urlPathHelper) { public PathMatchConfigurer setUrlPathHelper(UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
this.preferPathMatcher = true; this.preferPathMatcher = true;
@ -125,9 +123,12 @@ public class PathMatchConfigurer {
* {@link #setPatternParser(PathPatternParser)}. If set, it enables use of * {@link #setPatternParser(PathPatternParser)}. If set, it enables use of
* String path matching, unless a {@code PathPatternParser} is also * String path matching, unless a {@code PathPatternParser} is also
* explicitly set in which case this property is ignored. * explicitly set in which case this property is ignored.
* <p>By default this is an instance of {@link AntPathMatcher} with default * <p>By default, this is an instance of {@link AntPathMatcher} with default
* settings. * settings.
* @deprecated use of {@link PathMatcher} is deprecated for use at runtime
* in web modules in favor of parsed patterns with {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public PathMatchConfigurer setPathMatcher(PathMatcher pathMatcher) { public PathMatchConfigurer setPathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
this.preferPathMatcher = true; this.preferPathMatcher = true;
@ -143,7 +144,10 @@ public class PathMatchConfigurer {
* {@link PathMatcher} related option is explicitly set. * {@link PathMatcher} related option is explicitly set.
* </ul> * </ul>
* @since 6.0 * @since 6.0
* @deprecated use of {@link PathMatcher} is deprecated for use at runtime
* in web modules in favor of parsed patterns with {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected boolean preferPathMatcher() { protected boolean preferPathMatcher() {
return (this.patternParser == null && this.preferPathMatcher); return (this.patternParser == null && this.preferPathMatcher);
} }
@ -160,10 +164,12 @@ public class PathMatchConfigurer {
return this.pathPrefixes; return this.pathPrefixes;
} }
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable UrlPathHelper getUrlPathHelper() { public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable PathMatcher getPathMatcher() { public @Nullable PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
} }
@ -171,7 +177,11 @@ public class PathMatchConfigurer {
/** /**
* Return the configured UrlPathHelper or a default, shared instance otherwise. * Return the configured UrlPathHelper or a default, shared instance otherwise.
* @since 5.3 * @since 5.3
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected UrlPathHelper getUrlPathHelperOrDefault() { protected UrlPathHelper getUrlPathHelperOrDefault() {
if (this.urlPathHelper != null) { if (this.urlPathHelper != null) {
return this.urlPathHelper; return this.urlPathHelper;
@ -185,7 +195,10 @@ public class PathMatchConfigurer {
/** /**
* Return the configured PathMatcher or a default, shared instance otherwise. * Return the configured PathMatcher or a default, shared instance otherwise.
* @since 5.3 * @since 5.3
* @deprecated use of {@link PathMatcher} is deprecated for use at runtime
* in web modules in favor of parsed patterns with {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected PathMatcher getPathMatcherOrDefault() { protected PathMatcher getPathMatcherOrDefault() {
if (this.pathMatcher != null) { if (this.pathMatcher != null) {
return this.pathMatcher; return this.pathMatcher;

View File

@ -100,7 +100,10 @@ public class ResourceHandlerRegistry {
* {@link #ResourceHandlerRegistry(ApplicationContext, ServletContext, ContentNegotiationManager)} * {@link #ResourceHandlerRegistry(ApplicationContext, ServletContext, ContentNegotiationManager)}
* that also accepts the {@link UrlPathHelper} used for mapping requests to static resources. * that also accepts the {@link UrlPathHelper} used for mapping requests to static resources.
* @since 4.3.13 * @since 4.3.13
* @deprecated in favor of
* {@link #ResourceHandlerRegistry(ApplicationContext, ServletContext, ContentNegotiationManager)}
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext, public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext,
@Nullable ContentNegotiationManager contentNegotiationManager, @Nullable UrlPathHelper pathHelper) { @Nullable ContentNegotiationManager contentNegotiationManager, @Nullable UrlPathHelper pathHelper) {
@ -167,6 +170,7 @@ public class ResourceHandlerRegistry {
return new SimpleUrlHandlerMapping(urlMap, this.order); return new SimpleUrlHandlerMapping(urlMap, this.order);
} }
@SuppressWarnings("removal")
private ResourceHttpRequestHandler getRequestHandler(ResourceHandlerRegistration registration) { private ResourceHttpRequestHandler getRequestHandler(ResourceHandlerRegistration registration) {
ResourceHttpRequestHandler handler = registration.getRequestHandler(); ResourceHttpRequestHandler handler = registration.getRequestHandler();
if (this.pathHelper != null) { if (this.pathHelper != null) {

View File

@ -391,7 +391,12 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* <p><b>Note:</b> This is only used when parsed patterns are not * <p><b>Note:</b> This is only used when parsed patterns are not
* {@link PathMatchConfigurer#setPatternParser enabled}. * {@link PathMatchConfigurer#setPatternParser enabled}.
* @since 4.1 * @since 4.1
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Bean @Bean
public UrlPathHelper mvcUrlPathHelper() { public UrlPathHelper mvcUrlPathHelper() {
return getPathMatchConfigurer().getUrlPathHelperOrDefault(); return getPathMatchConfigurer().getUrlPathHelperOrDefault();
@ -404,7 +409,12 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* <p><b>Note:</b> This is only used when parsed patterns are not * <p><b>Note:</b> This is only used when parsed patterns are not
* {@link PathMatchConfigurer#setPatternParser enabled}. * {@link PathMatchConfigurer#setPatternParser enabled}.
* @since 4.1 * @since 4.1
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Bean @Bean
public PathMatcher mvcPathMatcher() { public PathMatcher mvcPathMatcher() {
return getPathMatchConfigurer().getPathMatcherOrDefault(); return getPathMatchConfigurer().getPathMatcherOrDefault();
@ -474,6 +484,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
return mapping; return mapping;
} }
@SuppressWarnings("removal")
private void initHandlerMapping( private void initHandlerMapping(
@Nullable AbstractHandlerMapping mapping, FormattingConversionService conversionService, @Nullable AbstractHandlerMapping mapping, FormattingConversionService conversionService,
ResourceUrlProvider resourceUrlProvider) { ResourceUrlProvider resourceUrlProvider) {
@ -554,6 +565,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* resource handlers. To configure resource handling, override * resource handlers. To configure resource handling, override
* {@link #addResourceHandlers}. * {@link #addResourceHandlers}.
*/ */
@SuppressWarnings("removal")
@Bean @Bean
public @Nullable HandlerMapping resourceHandlerMapping( public @Nullable HandlerMapping resourceHandlerMapping(
@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager,
@ -585,6 +597,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
* A {@link ResourceUrlProvider} bean for use with the MVC dispatcher. * A {@link ResourceUrlProvider} bean for use with the MVC dispatcher.
* @since 4.1 * @since 4.1
*/ */
@SuppressWarnings("removal")
@Bean @Bean
public ResourceUrlProvider mvcResourceUrlProvider() { public ResourceUrlProvider mvcResourceUrlProvider() {
ResourceUrlProvider urlProvider = new ResourceUrlProvider(); ResourceUrlProvider urlProvider = new ResourceUrlProvider();

View File

@ -222,6 +222,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request); servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request);
} }
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Override @Override
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
throw new UnsupportedOperationException("This HandlerMapping uses PathPatterns"); throw new UnsupportedOperationException("This HandlerMapping uses PathPatterns");

View File

@ -179,6 +179,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath(boolean) * @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath(boolean)
* @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)} * @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)}
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
public void setAlwaysUseFullPath(boolean alwaysUseFullPath) { public void setAlwaysUseFullPath(boolean alwaysUseFullPath) {
this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath); this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath);
@ -194,6 +195,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see org.springframework.web.util.UrlPathHelper#setUrlDecode(boolean) * @see org.springframework.web.util.UrlPathHelper#setUrlDecode(boolean)
* @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)} * @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)}
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
public void setUrlDecode(boolean urlDecode) { public void setUrlDecode(boolean urlDecode) {
this.urlPathHelper.setUrlDecode(urlDecode); this.urlPathHelper.setUrlDecode(urlDecode);
@ -209,6 +211,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean) * @see org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)
* @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)} * @deprecated as of 6.0, in favor of using {@link #setUrlPathHelper(UrlPathHelper)}
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
public void setRemoveSemicolonContent(boolean removeSemicolonContent) { public void setRemoveSemicolonContent(boolean removeSemicolonContent) {
this.urlPathHelper.setRemoveSemicolonContent(removeSemicolonContent); this.urlPathHelper.setRemoveSemicolonContent(removeSemicolonContent);
@ -221,7 +224,12 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* Configure the UrlPathHelper to use for resolution of lookup paths. * Configure the UrlPathHelper to use for resolution of lookup paths.
* <p><strong>Note:</strong> This property is mutually exclusive with and * <p><strong>Note:</strong> This property is mutually exclusive with and
* ignored when {@link #setPatternParser(PathPatternParser)} is set. * ignored when {@link #setPatternParser(PathPatternParser)} is set.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); Assert.notNull(urlPathHelper, "UrlPathHelper must not be null");
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
@ -232,7 +240,11 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
/** /**
* Return the {@link #setUrlPathHelper configured} {@code UrlPathHelper}. * Return the {@link #setUrlPathHelper configured} {@code UrlPathHelper}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public UrlPathHelper getUrlPathHelper() { public UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@ -241,9 +253,14 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* Configure the PathMatcher to use. * Configure the PathMatcher to use.
* <p><strong>Note:</strong> This property is mutually exclusive with and * <p><strong>Note:</strong> This property is mutually exclusive with and
* ignored when {@link #setPatternParser(PathPatternParser)} is set. * ignored when {@link #setPatternParser(PathPatternParser)} is set.
* <p>By default this is {@link AntPathMatcher}. * <p>By default, this is {@link AntPathMatcher}.
* @see org.springframework.util.AntPathMatcher * @see org.springframework.util.AntPathMatcher
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(PathMatcher pathMatcher) { public void setPathMatcher(PathMatcher pathMatcher) {
Assert.notNull(pathMatcher, "PathMatcher must not be null"); Assert.notNull(pathMatcher, "PathMatcher must not be null");
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
@ -254,7 +271,11 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
/** /**
* Return the {@link #setPathMatcher configured} {@code PathMatcher}. * Return the {@link #setPathMatcher configured} {@code PathMatcher}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public PathMatcher getPathMatcher() { public PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
} }
@ -311,6 +332,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @since 4.2 * @since 4.2
* @see #setCorsProcessor(CorsProcessor) * @see #setCorsProcessor(CorsProcessor)
*/ */
@SuppressWarnings("removal")
public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) { public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) {
if (CollectionUtils.isEmpty(corsConfigurations)) { if (CollectionUtils.isEmpty(corsConfigurations)) {
this.corsConfigurationSource = null; this.corsConfigurationSource = null;
@ -339,6 +361,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @since 5.1 * @since 5.1
* @see #setCorsProcessor(CorsProcessor) * @see #setCorsProcessor(CorsProcessor)
*/ */
@SuppressWarnings("removal")
public void setCorsConfigurationSource(CorsConfigurationSource source) { public void setCorsConfigurationSource(CorsConfigurationSource source) {
Assert.notNull(source, "CorsConfigurationSource must not be null"); Assert.notNull(source, "CorsConfigurationSource must not be null");
this.corsConfigurationSource = source; this.corsConfigurationSource = source;

View File

@ -525,6 +525,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* Return the request mapping paths that are not patterns. * Return the request mapping paths that are not patterns.
* @since 5.3 * @since 5.3
*/ */
@SuppressWarnings("removal")
protected Set<String> getDirectPaths(T mapping) { protected Set<String> getDirectPaths(T mapping) {
Set<String> urls = Collections.emptySet(); Set<String> urls = Collections.emptySet();
for (String path : getMappingPathPatterns(mapping)) { for (String path : getMappingPathPatterns(mapping)) {

View File

@ -319,6 +319,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* @see #exposePathWithinMapping * @see #exposePathWithinMapping
* @see AntPathMatcher * @see AntPathMatcher
*/ */
@SuppressWarnings("removal")
protected @Nullable Object lookupHandler(String lookupPath, HttpServletRequest request) throws Exception { protected @Nullable Object lookupHandler(String lookupPath, HttpServletRequest request) throws Exception {
Object handler = getDirectMatch(lookupPath, request); Object handler = getDirectMatch(lookupPath, request);
if (handler != null) { if (handler != null) {
@ -452,7 +453,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVariables); request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVariables);
} }
@SuppressWarnings("removal")
@Override @Override
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns."); Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns.");
String lookupPath = UrlPathHelper.getResolvedLookupPath(request); String lookupPath = UrlPathHelper.getResolvedLookupPath(request);

View File

@ -570,6 +570,8 @@ public class HandlerMappingIntrospector
return this.delegate.getPatternParser(); return this.delegate.getPatternParser();
} }
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Override @Override
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
pattern = initFullPathPattern(pattern); pattern = initFullPathPattern(pattern);

View File

@ -172,14 +172,22 @@ public final class MappedInterceptor implements HandlerInterceptor {
* String pattern matching even when a * String pattern matching even when a
* {@linkplain ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath} * {@linkplain ServletRequestPathUtils#parseAndCache parsed} {@code RequestPath}
* is available. * is available.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(PathMatcher pathMatcher) { public void setPathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
} }
/** /**
* Get the {@linkplain #setPathMatcher(PathMatcher) configured} PathMatcher. * Get the {@linkplain #setPathMatcher(PathMatcher) configured} PathMatcher.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public PathMatcher getPathMatcher() { public PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,9 @@ package org.springframework.web.servlet.handler;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser; import org.springframework.web.util.pattern.PathPatternParser;
/** /**
@ -49,7 +51,11 @@ public interface MatchableHandlerMapping extends HandlerMapping {
* @param request the current request * @param request the current request
* @param pattern the pattern to match * @param pattern the pattern to match
* @return the result from request matching, or {@code null} if none * @return the result from request matching, or {@code null} if none
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
@Nullable RequestMatchResult match(HttpServletRequest request, String pattern); @Nullable RequestMatchResult match(HttpServletRequest request, String pattern);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,6 +56,8 @@ class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping {
this.parser = delegate.getPatternParser(); this.parser = delegate.getPatternParser();
} }
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Override @Override
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
PathPattern pathPattern = this.pathPatternCache.computeIfAbsent(pattern, value -> { PathPattern pathPattern = this.pathPatternCache.computeIfAbsent(pattern, value -> {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,9 @@ import org.jspecify.annotations.Nullable;
import org.springframework.http.server.PathContainer; import org.springframework.http.server.PathContainer;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PathMatcher; import org.springframework.util.PathMatcher;
import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPattern;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* Container for the result from request pattern matching via * Container for the result from request pattern matching via
@ -71,7 +73,11 @@ public class RequestMatchResult {
* @param pattern the pattern that was matched, possibly with a '/' appended * @param pattern the pattern that was matched, possibly with a '/' appended
* @param lookupPath the mapping path * @param lookupPath the mapping path
* @param pathMatcher the PathMatcher instance used for the match * @param pathMatcher the PathMatcher instance used for the match
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public RequestMatchResult(String pattern, String lookupPath, PathMatcher pathMatcher) { public RequestMatchResult(String pattern, String lookupPath, PathMatcher pathMatcher) {
Assert.hasText(pattern, "'matchingPattern' is required"); Assert.hasText(pattern, "'matchingPattern' is required");
Assert.hasText(lookupPath, "'lookupPath' is required"); Assert.hasText(lookupPath, "'lookupPath' is required");
@ -87,7 +93,7 @@ public class RequestMatchResult {
/** /**
* Extract URI template variables from the matching pattern as defined in * Extract URI template variables from the matching pattern as defined in
* {@link PathMatcher#extractUriTemplateVariables}. * {@link PathPattern#matchAndExtract(PathContainer)}.
* @return a map with URI template variables * @return a map with URI template variables
*/ */
@SuppressWarnings({"ConstantConditions", "NullAway"}) @SuppressWarnings({"ConstantConditions", "NullAway"})

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,9 +20,11 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.support.RequestContextUtils; import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* Abstract base class for {@code Controllers} that return a view name * Abstract base class for {@code Controllers} that return a view name
@ -48,7 +50,11 @@ public abstract class AbstractUrlViewController extends AbstractController {
* if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml). * if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml).
* Default is "false". * Default is "false".
* @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath * @see org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setAlwaysUseFullPath(boolean alwaysUseFullPath) { public void setAlwaysUseFullPath(boolean alwaysUseFullPath) {
this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath); this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath);
} }
@ -60,7 +66,11 @@ public abstract class AbstractUrlViewController extends AbstractController {
* <p>Uses either the request encoding or the default encoding according * <p>Uses either the request encoding or the default encoding according
* to the Servlet spec (ISO-8859-1). * to the Servlet spec (ISO-8859-1).
* @see org.springframework.web.util.UrlPathHelper#setUrlDecode * @see org.springframework.web.util.UrlPathHelper#setUrlDecode
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlDecode(boolean urlDecode) { public void setUrlDecode(boolean urlDecode) {
this.urlPathHelper.setUrlDecode(urlDecode); this.urlPathHelper.setUrlDecode(urlDecode);
} }
@ -68,7 +78,11 @@ public abstract class AbstractUrlViewController extends AbstractController {
/** /**
* Set if ";" (semicolon) content should be stripped from the request URI. * Set if ";" (semicolon) content should be stripped from the request URI.
* @see org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean) * @see org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setRemoveSemicolonContent(boolean removeSemicolonContent) { public void setRemoveSemicolonContent(boolean removeSemicolonContent) {
this.urlPathHelper.setRemoveSemicolonContent(removeSemicolonContent); this.urlPathHelper.setRemoveSemicolonContent(removeSemicolonContent);
} }
@ -79,7 +93,11 @@ public abstract class AbstractUrlViewController extends AbstractController {
* or to share common UrlPathHelper settings across multiple MethodNameResolvers * or to share common UrlPathHelper settings across multiple MethodNameResolvers
* and HandlerMappings. * and HandlerMappings.
* @see org.springframework.web.servlet.handler.AbstractUrlHandlerMapping#setUrlPathHelper * @see org.springframework.web.servlet.handler.AbstractUrlHandlerMapping#setUrlPathHelper
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); Assert.notNull(urlPathHelper, "UrlPathHelper must not be null");
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
@ -87,7 +105,11 @@ public abstract class AbstractUrlViewController extends AbstractController {
/** /**
* Return the UrlPathHelper to use for the resolution of lookup paths. * Return the UrlPathHelper to use for the resolution of lookup paths.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected UrlPathHelper getUrlPathHelper() { protected UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -73,7 +73,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
*/ */
public class WebContentInterceptor extends WebContentGenerator implements HandlerInterceptor { public class WebContentInterceptor extends WebContentGenerator implements HandlerInterceptor {
private static PathMatcher defaultPathMatcher = new AntPathMatcher(); private static final PathMatcher defaultPathMatcher = new AntPathMatcher();
private final PathPatternParser patternParser; private final PathPatternParser patternParser;
@ -148,7 +148,11 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* @see #addCacheMapping * @see #addCacheMapping
* @see #setCacheMappings * @see #setCacheMappings
* @see org.springframework.util.AntPathMatcher * @see org.springframework.util.AntPathMatcher
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(PathMatcher pathMatcher) { public void setPathMatcher(PathMatcher pathMatcher) {
Assert.notNull(pathMatcher, "PathMatcher must not be null"); Assert.notNull(pathMatcher, "PathMatcher must not be null");
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
@ -265,7 +269,11 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* relies on String pattern matching with {@link PathMatcher}. * relies on String pattern matching with {@link PathMatcher}.
* @param lookupPath the path to match to * @param lookupPath the path to match to
* @return the matched {@code CacheControl}, or {@code null} if no match * @return the matched {@code CacheControl}, or {@code null} if no match
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected @Nullable CacheControl lookupCacheControl(String lookupPath) { protected @Nullable CacheControl lookupCacheControl(String lookupPath) {
for (Map.Entry<PathPattern, CacheControl> entry : this.cacheControlMappings.entrySet()) { for (Map.Entry<PathPattern, CacheControl> entry : this.cacheControlMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) { if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) {
@ -297,7 +305,11 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
* matching with {@link PathMatcher}. * matching with {@link PathMatcher}.
* @param lookupPath the path to match to * @param lookupPath the path to match to
* @return the matched cacheSeconds, or {@code null} if there is no match * @return the matched cacheSeconds, or {@code null} if there is no match
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
protected @Nullable Integer lookupCacheSeconds(String lookupPath) { protected @Nullable Integer lookupCacheSeconds(String lookupPath) {
for (Map.Entry<PathPattern, Integer> entry : this.cacheMappings.entrySet()) { for (Map.Entry<PathPattern, Integer> entry : this.cacheMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) { if (this.pathMatcher.match(entry.getKey().getPatternString(), lookupPath)) {

View File

@ -48,7 +48,11 @@ import org.springframework.web.util.pattern.PathPatternParser;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1 * @since 3.1
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public class PatternsRequestCondition extends AbstractRequestCondition<PatternsRequestCondition> { public class PatternsRequestCondition extends AbstractRequestCondition<PatternsRequestCondition> {
private static final Set<String> EMPTY_PATH_PATTERN = Collections.singleton(""); private static final Set<String> EMPTY_PATH_PATTERN = Collections.singleton("");

View File

@ -65,6 +65,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
private static final PathPatternsRequestCondition EMPTY_PATH_PATTERNS = new PathPatternsRequestCondition(); private static final PathPatternsRequestCondition EMPTY_PATH_PATTERNS = new PathPatternsRequestCondition();
@SuppressWarnings("removal")
private static final PatternsRequestCondition EMPTY_PATTERNS = new PatternsRequestCondition(); private static final PatternsRequestCondition EMPTY_PATTERNS = new PatternsRequestCondition();
private static final RequestMethodsRequestCondition EMPTY_REQUEST_METHODS = new RequestMethodsRequestCondition(); private static final RequestMethodsRequestCondition EMPTY_REQUEST_METHODS = new RequestMethodsRequestCondition();
@ -84,6 +85,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
private final @Nullable PathPatternsRequestCondition pathPatternsCondition; private final @Nullable PathPatternsRequestCondition pathPatternsCondition;
@SuppressWarnings("removal")
private final @Nullable PatternsRequestCondition patternsCondition; private final @Nullable PatternsRequestCondition patternsCondition;
private final RequestMethodsRequestCondition methodsCondition; private final RequestMethodsRequestCondition methodsCondition;
@ -108,6 +110,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* @deprecated as of 5.3 in favor using {@link RequestMappingInfo.Builder} via * @deprecated as of 5.3 in favor using {@link RequestMappingInfo.Builder} via
* {@link #paths(String...)}. * {@link #paths(String...)}.
*/ */
@SuppressWarnings("removal")
@Deprecated @Deprecated
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns,
@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
@ -130,6 +133,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* @deprecated as of 5.3 in favor using {@link RequestMappingInfo.Builder} via * @deprecated as of 5.3 in favor using {@link RequestMappingInfo.Builder} via
* {@link #paths(String...)}. * {@link #paths(String...)}.
*/ */
@SuppressWarnings("removal")
@Deprecated @Deprecated
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, public RequestMappingInfo(@Nullable PatternsRequestCondition patterns,
@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
@ -149,6 +153,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
info.consumesCondition, info.producesCondition, customRequestCondition); info.consumesCondition, info.producesCondition, customRequestCondition);
} }
@SuppressWarnings("removal")
private RequestMappingInfo(@Nullable String name, private RequestMappingInfo(@Nullable String name,
@Nullable PathPatternsRequestCondition pathPatternsCondition, @Nullable PathPatternsRequestCondition pathPatternsCondition,
@Nullable PatternsRequestCondition patternsCondition, @Nullable PatternsRequestCondition patternsCondition,
@ -202,7 +207,12 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* {@link PathMatcher} is in use. * {@link PathMatcher} is in use.
* <p>This is mutually exclusive with {@link #getPathPatternsCondition()} * <p>This is mutually exclusive with {@link #getPathPatternsCondition()}
* such that when one returns {@code null} the other one returns an instance. * such that when one returns {@code null} the other one returns an instance.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable PatternsRequestCondition getPatternsCondition() { public @Nullable PatternsRequestCondition getPatternsCondition() {
return this.patternsCondition; return this.patternsCondition;
} }
@ -230,6 +240,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* Return the mapping paths that are not patterns. * Return the mapping paths that are not patterns.
* @since 5.3 * @since 5.3
*/ */
@SuppressWarnings("removal")
public Set<String> getDirectPaths() { public Set<String> getDirectPaths() {
RequestCondition<?> condition = getActivePatternsCondition(); RequestCondition<?> condition = getActivePatternsCondition();
return (condition instanceof PathPatternsRequestCondition pprc ? return (condition instanceof PathPatternsRequestCondition pprc ?
@ -241,6 +252,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* patterns condition as Strings. * patterns condition as Strings.
* @since 5.3 * @since 5.3
*/ */
@SuppressWarnings("removal")
public Set<String> getPatternValues() { public Set<String> getPatternValues() {
RequestCondition<?> condition = getActivePatternsCondition(); RequestCondition<?> condition = getActivePatternsCondition();
return (condition instanceof PathPatternsRequestCondition pprc ? return (condition instanceof PathPatternsRequestCondition pprc ?
@ -251,6 +263,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* Whether the request mapping has an empty URL path mapping. * Whether the request mapping has an empty URL path mapping.
* @since 6.0.10 * @since 6.0.10
*/ */
@SuppressWarnings("removal")
public boolean isEmptyMapping() { public boolean isEmptyMapping() {
RequestCondition<?> condition = getActivePatternsCondition(); RequestCondition<?> condition = getActivePatternsCondition();
return (condition instanceof PathPatternsRequestCondition pprc ? return (condition instanceof PathPatternsRequestCondition pprc ?
@ -324,6 +337,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* <p>Example: combine type- and method-level request mappings. * <p>Example: combine type- and method-level request mappings.
* @return a new request mapping info instance; never {@code null} * @return a new request mapping info instance; never {@code null}
*/ */
@SuppressWarnings("removal")
@Override @Override
public RequestMappingInfo combine(RequestMappingInfo other) { public RequestMappingInfo combine(RequestMappingInfo other) {
String name = combineNames(other); String name = combineNames(other);
@ -369,6 +383,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* patterns on top. * patterns on top.
* @return a new instance in case of a match; or {@code null} otherwise * @return a new instance in case of a match; or {@code null} otherwise
*/ */
@SuppressWarnings("removal")
@Override @Override
public @Nullable RequestMappingInfo getMatchingCondition(HttpServletRequest request) { public @Nullable RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request); RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
@ -479,7 +494,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
return this.hashCode; return this.hashCode;
} }
@SuppressWarnings({"ConstantConditions", "NullAway"}) @SuppressWarnings({"ConstantConditions", "NullAway", "removal"})
private static int calculateHashCode( private static int calculateHashCode(
@Nullable PathPatternsRequestCondition pathPatterns, @Nullable PatternsRequestCondition patterns, @Nullable PathPatternsRequestCondition pathPatterns, @Nullable PatternsRequestCondition patterns,
RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers, RequestMethodsRequestCondition methods, ParamsRequestCondition params, HeadersRequestCondition headers,
@ -688,6 +703,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
return this; return this;
} }
@SuppressWarnings("removal")
@Override @Override
public RequestMappingInfo build() { public RequestMappingInfo build() {
@ -733,6 +749,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
private @Nullable PathPatternsRequestCondition pathPatternsCondition; private @Nullable PathPatternsRequestCondition pathPatternsCondition;
@SuppressWarnings("removal")
private @Nullable PatternsRequestCondition patternsCondition; private @Nullable PatternsRequestCondition patternsCondition;
private RequestMethodsRequestCondition methodsCondition; private RequestMethodsRequestCondition methodsCondition;
@ -762,6 +779,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
this.options = other.options; this.options = other.options;
} }
@SuppressWarnings("removal")
@Override @Override
public Builder paths(String... paths) { public Builder paths(String... paths) {
PathPatternParser parser = this.options.getPatternParserToUse(); PathPatternParser parser = this.options.getPatternParserToUse();
@ -912,14 +930,22 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
* <p>By default, this is not set. You must set it explicitly if you want * <p>By default, this is not set. You must set it explicitly if you want
* {@link PathMatcher} to be used, or otherwise {@link RequestMappingInfo} * {@link PathMatcher} to be used, or otherwise {@link RequestMappingInfo}
* defaults to using {@link PathPatternParser}. * defaults to using {@link PathPatternParser}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(@Nullable PathMatcher pathMatcher) { public void setPathMatcher(@Nullable PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
} }
/** /**
* Return a custom PathMatcher to use for the PatternsRequestCondition, if any. * Return a custom PathMatcher to use for the PatternsRequestCondition, if any.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable PathMatcher getPathMatcher() { public @Nullable PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
} }

View File

@ -135,6 +135,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
* @see HandlerMapping#MATRIX_VARIABLES_ATTRIBUTE * @see HandlerMapping#MATRIX_VARIABLES_ATTRIBUTE
* @see HandlerMapping#PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE * @see HandlerMapping#PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE
*/ */
@SuppressWarnings("removal")
@Override @Override
protected void handleMatch(RequestMappingInfo info, String lookupPath, HttpServletRequest request) { protected void handleMatch(RequestMappingInfo info, String lookupPath, HttpServletRequest request) {
super.handleMatch(info, lookupPath, request); super.handleMatch(info, lookupPath, request);
@ -180,6 +181,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables); request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
} }
@SuppressWarnings("removal")
private void extractMatchDetails( private void extractMatchDetails(
PatternsRequestCondition condition, String lookupPath, HttpServletRequest request) { PatternsRequestCondition condition, String lookupPath, HttpServletRequest request) {
@ -203,6 +205,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables); request.setAttribute(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
} }
@SuppressWarnings("removal")
private Map<String, MultiValueMap<String, String>> extractMatrixVariables( private Map<String, MultiValueMap<String, String>> extractMatrixVariables(
HttpServletRequest request, Map<String, String> uriVariables) { HttpServletRequest request, Map<String, String> uriVariables) {

View File

@ -135,7 +135,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void afterPropertiesSet() { public void afterPropertiesSet() {
this.config = new RequestMappingInfo.BuilderConfiguration(); this.config = new RequestMappingInfo.BuilderConfiguration();
this.config.setContentNegotiationManager(getContentNegotiationManager()); this.config.setContentNegotiationManager(getContentNegotiationManager());
@ -390,6 +390,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
} }
} }
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Override @Override
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns."); Assert.state(getPatternParser() == null, "This HandlerMapping uses PathPatterns.");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,10 +23,12 @@ import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PathMatcher;
import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver; import org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.WebUtils; import org.springframework.web.util.WebUtils;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* An {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver} * An {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver}
@ -37,7 +39,7 @@ import org.springframework.web.util.WebUtils;
*/ */
public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValueMethodArgumentResolver { public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValueMethodArgumentResolver {
private UrlPathHelper urlPathHelper = new UrlPathHelper(); private UrlPathHelper urlPathHelper = UrlPathHelper.defaultInstance;
public ServletCookieValueMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory) { public ServletCookieValueMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory) {
@ -50,18 +52,23 @@ public class ServletCookieValueMethodArgumentResolver extends AbstractCookieValu
* {@link UrlPathHelper#decodeRequestString(HttpServletRequest, String)}. * {@link UrlPathHelper#decodeRequestString(HttpServletRequest, String)}.
* A shortcut for doing the same by setting a {@link UrlPathHelper} with * A shortcut for doing the same by setting a {@link UrlPathHelper} with
* its {@code urlDecode} property set accordingly. * its {@code urlDecode} property set accordingly.
* <p>By default set to "true" in which case cookie values are decoded. * <p>By default, set to "true" in which case cookie values are decoded.
* @since 6.1.2 * @since 6.1.2
*/ */
public void setUrlDecode(boolean urlDecode) { public void setUrlDecode(boolean urlDecode) {
this.urlPathHelper.setUrlDecode(urlDecode); this.urlPathHelper = (urlDecode ? UrlPathHelper.defaultInstance : UrlPathHelper.rawPathInstance);
} }
/** /**
* Set the {@code UrlPathHelper} to use to decode cookie values with via * Set the {@code UrlPathHelper} to use to decode cookie values with via
* {@link UrlPathHelper#decodeRequestString(HttpServletRequest, String)}. * {@link UrlPathHelper#decodeRequestString(HttpServletRequest, String)}.
* For most cases you can use {@link #setUrlDecode(boolean)} instead. * For most cases you can use {@link #setUrlDecode(boolean)} instead.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }

View File

@ -33,10 +33,12 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource; import org.springframework.core.io.UrlResource;
import org.springframework.core.log.LogFormatUtils; import org.springframework.core.log.LogFormatUtils;
import org.springframework.http.server.PathContainer; import org.springframework.http.server.PathContainer;
import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.util.ServletRequestPathUtils; import org.springframework.web.util.ServletRequestPathUtils;
import org.springframework.web.util.UriUtils; import org.springframework.web.util.UriUtils;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* A simple {@code ResourceResolver} that tries to find a resource under the given * A simple {@code ResourceResolver} that tries to find a resource under the given
@ -111,7 +113,11 @@ public class PathResourceResolver extends AbstractResourceResolver {
* static resources. This helps to derive information about the lookup path * static resources. This helps to derive information about the lookup path
* such as whether it is decoded or not. * such as whether it is decoded or not.
* @since 4.3.13 * @since 4.3.13
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) { public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }
@ -119,7 +125,11 @@ public class PathResourceResolver extends AbstractResourceResolver {
/** /**
* The configured {@link UrlPathHelper}. * The configured {@link UrlPathHelper}.
* @since 4.3.13 * @since 4.3.13
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable UrlPathHelper getUrlPathHelper() { public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }

View File

@ -49,6 +49,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.util.StringValueResolver; import org.springframework.util.StringValueResolver;
import org.springframework.web.HttpRequestHandler; import org.springframework.web.HttpRequestHandler;
@ -60,6 +61,7 @@ import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.support.WebContentGenerator; import org.springframework.web.servlet.support.WebContentGenerator;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* {@code HttpRequestHandler} that serves static resources in an optimized way * {@code HttpRequestHandler} that serves static resources in an optimized way
@ -314,7 +316,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
* static resources. This helps to derive information about the lookup path * static resources. This helps to derive information about the lookup path
* such as whether it is decoded or not. * such as whether it is decoded or not.
* @since 4.3.13 * @since 4.3.13
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) { public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }
@ -322,7 +328,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
/** /**
* The configured {@link UrlPathHelper}. * The configured {@link UrlPathHelper}.
* @since 4.3.13 * @since 4.3.13
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable UrlPathHelper getUrlPathHelper() { public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@ -477,6 +487,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
* resolvers and set its {@code allowedLocations} property (if empty) to * resolvers and set its {@code allowedLocations} property (if empty) to
* match the {@link #setLocations locations} configured on this class. * match the {@link #setLocations locations} configured on this class.
*/ */
@SuppressWarnings("removal")
protected void initAllowedLocations() { protected void initAllowedLocations() {
if (CollectionUtils.isEmpty(getLocations())) { if (CollectionUtils.isEmpty(getLocations())) {
return; return;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -91,6 +91,7 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
* @param request the referer request * @param request the referer request
* @return the absolute request path for the given resource path * @return the absolute request path for the given resource path
*/ */
@SuppressWarnings("removal")
protected String toAbsolutePath(String path, HttpServletRequest request) { protected String toAbsolutePath(String path, HttpServletRequest request) {
String absolutePath = path; String absolutePath = path;
if (!path.startsWith("/")) { if (!path.startsWith("/")) {

View File

@ -89,6 +89,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
} }
} }
@SuppressWarnings("removal")
private void initLookupPath(ResourceUrlProvider urlProvider) { private void initLookupPath(ResourceUrlProvider urlProvider) {
this.resourceUrlProvider = urlProvider; this.resourceUrlProvider = urlProvider;
if (this.indexLookupPath == null) { if (this.indexLookupPath == null) {

View File

@ -75,7 +75,11 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
* Configure a {@code UrlPathHelper} to use in * Configure a {@code UrlPathHelper} to use in
* {@link #getForRequestUrl(jakarta.servlet.http.HttpServletRequest, String)} * {@link #getForRequestUrl(jakarta.servlet.http.HttpServletRequest, String)}
* in order to derive the lookup path for a target request URL path. * in order to derive the lookup path for a target request URL path.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules. After the deprecation phase, it will no
* longer be possible to set a customized PathMatcher instance.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }
@ -83,7 +87,11 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
/** /**
* Return the configured {@code UrlPathHelper}. * Return the configured {@code UrlPathHelper}.
* @since 4.2.8 * @since 4.2.8
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules. After the deprecation phase, it will no
* longer be possible to set a customized PathMatcher instance.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public UrlPathHelper getUrlPathHelper() { public UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@ -91,14 +99,22 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
/** /**
* Configure a {@code PathMatcher} to use when comparing target lookup path * Configure a {@code PathMatcher} to use when comparing target lookup path
* against resource mappings. * against resource mappings.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules. After the deprecation phase, it will no
* longer be possible to set a customized PathMatcher instance.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setPathMatcher(PathMatcher pathMatcher) { public void setPathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher; this.pathMatcher = pathMatcher;
} }
/** /**
* Return the configured {@code PathMatcher}. * Return the configured {@code PathMatcher}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules. After the deprecation phase, it will no
* longer be possible to set a customized PathMatcher instance.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public PathMatcher getPathMatcher() { public PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
} }
@ -181,6 +197,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
return (resolvedLookupPath != null ? prefix + resolvedLookupPath + suffix : null); return (resolvedLookupPath != null ? prefix + resolvedLookupPath + suffix : null);
} }
@SuppressWarnings("removal")
private int getLookupPathIndex(HttpServletRequest request) { private int getLookupPathIndex(HttpServletRequest request) {
UrlPathHelper pathHelper = getUrlPathHelper(); UrlPathHelper pathHelper = getUrlPathHelper();
if (request.getAttribute(UrlPathHelper.PATH_ATTRIBUTE) == null) { if (request.getAttribute(UrlPathHelper.PATH_ATTRIBUTE) == null) {

View File

@ -31,10 +31,12 @@ import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.servlet.FlashMap; import org.springframework.web.servlet.FlashMap;
import org.springframework.web.servlet.FlashMapManager; import org.springframework.web.servlet.FlashMapManager;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* A base class for {@link FlashMapManager} implementations. * A base class for {@link FlashMapManager} implementations.
@ -74,7 +76,11 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
/** /**
* Set the UrlPathHelper to use to match FlashMap instances to requests. * Set the UrlPathHelper to use to match FlashMap instances to requests.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); Assert.notNull(urlPathHelper, "UrlPathHelper must not be null");
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
@ -82,7 +88,11 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
/** /**
* Return the UrlPathHelper implementation to use. * Return the UrlPathHelper implementation to use.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public UrlPathHelper getUrlPathHelper() { public UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }

View File

@ -37,6 +37,7 @@ import org.springframework.context.i18n.SimpleTimeZoneAwareLocaleContext;
import org.springframework.context.i18n.TimeZoneAwareLocaleContext; import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -49,6 +50,7 @@ import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.WebUtils; import org.springframework.web.util.WebUtils;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* Context holder for request-specific state, like current web application context, current locale, * Context holder for request-specific state, like current web application context, current locale,
@ -499,7 +501,11 @@ public class RequestContext {
* Set the UrlPathHelper to use for context path and request URI decoding. * Set the UrlPathHelper to use for context path and request URI decoding.
* Can be used to pass a shared UrlPathHelper instance in. * Can be used to pass a shared UrlPathHelper instance in.
* <p>A default UrlPathHelper is always available. * <p>A default UrlPathHelper is always available.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(UrlPathHelper urlPathHelper) { public void setUrlPathHelper(UrlPathHelper urlPathHelper) {
Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); Assert.notNull(urlPathHelper, "UrlPathHelper must not be null");
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
@ -509,7 +515,11 @@ public class RequestContext {
* Return the UrlPathHelper used for context path and request URI decoding. * Return the UrlPathHelper used for context path and request URI decoding.
* Can be used to configure the current UrlPathHelper. * Can be used to configure the current UrlPathHelper.
* <p>A default UrlPathHelper is always available. * <p>A default UrlPathHelper is always available.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public UrlPathHelper getUrlPathHelper() { public UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }

View File

@ -78,6 +78,7 @@ class AnnotationDrivenBeanDefinitionParserTests {
.asInstanceOf(BOOLEAN).isTrue(); .asInstanceOf(BOOLEAN).isTrue();
} }
@SuppressWarnings("removal")
@Test @Test
public void testPathMatchingConfiguration() { public void testPathMatchingConfiguration() {
loadBeanDefinitions("mvc-config-path-matching.xml"); loadBeanDefinitions("mvc-config-path-matching.xml");

View File

@ -196,6 +196,7 @@ public class MvcNamespaceTests {
} }
@SuppressWarnings("removal")
@Test @Test
void testDefaultConfig() throws Exception { void testDefaultConfig() throws Exception {
loadBeanDefinitions("mvc-config.xml"); loadBeanDefinitions("mvc-config.xml");
@ -325,6 +326,7 @@ public class MvcNamespaceTests {
doTestCustomValidator("mvc-config-custom-validator.xml"); doTestCustomValidator("mvc-config-custom-validator.xml");
} }
@SuppressWarnings("removal")
private void doTestCustomValidator(String xml) throws Exception { private void doTestCustomValidator(String xml) throws Exception {
loadBeanDefinitions(xml); loadBeanDefinitions(xml);
@ -379,6 +381,7 @@ public class MvcNamespaceTests {
assertThat(chain.getInterceptorList()).hasSize(3); assertThat(chain.getInterceptorList()).hasSize(3);
} }
@SuppressWarnings("removal")
@Test @Test
void testResources() throws Exception { void testResources() throws Exception {
loadBeanDefinitions("mvc-config-resources.xml"); loadBeanDefinitions("mvc-config-resources.xml");
@ -425,6 +428,7 @@ public class MvcNamespaceTests {
.isInstanceOf(NoResourceFoundException.class); .isInstanceOf(NoResourceFoundException.class);
} }
@SuppressWarnings("removal")
@Test @Test
void testUseDeprecatedPathMatcher() throws Exception { void testUseDeprecatedPathMatcher() throws Exception {
loadBeanDefinitions("mvc-config-deprecated-path-matcher.xml"); loadBeanDefinitions("mvc-config-deprecated-path-matcher.xml");
@ -437,6 +441,7 @@ public class MvcNamespaceTests {
}); });
} }
@SuppressWarnings("removal")
@Test @Test
void testUsePathPatternParser() throws Exception { void testUsePathPatternParser() throws Exception {
loadBeanDefinitions("mvc-config-custom-pattern-parser.xml"); loadBeanDefinitions("mvc-config-custom-pattern-parser.xml");
@ -465,6 +470,7 @@ public class MvcNamespaceTests {
assertThat(handler.getCacheSeconds()).isEqualTo(3600); assertThat(handler.getCacheSeconds()).isEqualTo(3600);
} }
@SuppressWarnings("removal")
@Test @Test
void testResourcesWithResolversTransformers() { void testResourcesWithResolversTransformers() {
loadBeanDefinitions("mvc-config-resources-chain.xml"); loadBeanDefinitions("mvc-config-resources-chain.xml");
@ -615,6 +621,7 @@ public class MvcNamespaceTests {
assertThat(interceptor2.getParamName()).isEqualTo("style"); assertThat(interceptor2.getParamName()).isEqualTo("style");
} }
@SuppressWarnings("removal")
@Test @Test
void testViewControllers() throws Exception { void testViewControllers() throws Exception {
loadBeanDefinitions("mvc-config-view-controllers.xml"); loadBeanDefinitions("mvc-config-view-controllers.xml");
@ -911,6 +918,7 @@ public class MvcNamespaceTests {
assertThat(compositeResolver.getOrder()).isEqualTo(123); assertThat(compositeResolver.getOrder()).isEqualTo(123);
} }
@SuppressWarnings("removal")
@Test @Test
void testPathMatchingHandlerMappings() { void testPathMatchingHandlerMappings() {
loadBeanDefinitions("mvc-config-path-matching-mappings.xml"); loadBeanDefinitions("mvc-config-path-matching-mappings.xml");

View File

@ -70,6 +70,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
"mvcContentNegotiationManager", "testContentNegotiationManager"); "mvcContentNegotiationManager", "testContentNegotiationManager");
} }
@SuppressWarnings("removal")
@Test @Test
void viewControllerHandlerMappingUsesMvcInfrastructureByDefault() { void viewControllerHandlerMappingUsesMvcInfrastructureByDefault() {
load(context -> context.registerBean(ViewControllerConfiguration.class)); load(context -> context.registerBean(ViewControllerConfiguration.class));
@ -78,6 +79,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper")); assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper"));
} }
@SuppressWarnings("removal")
@Test @Test
void viewControllerHandlerMappingWithPrimaryUsesQualifiedPathMatcher() { void viewControllerHandlerMappingWithPrimaryUsesQualifiedPathMatcher() {
load(registerPrimaryBean("testPathMatcher", PathMatcher.class) load(registerPrimaryBean("testPathMatcher", PathMatcher.class)
@ -88,6 +90,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
"mvcPathMatcher", "testPathMatcher"); "mvcPathMatcher", "testPathMatcher");
} }
@SuppressWarnings("removal")
@Test @Test
void viewControllerHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() { void viewControllerHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() {
load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class) load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class)
@ -98,6 +101,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
"mvcUrlPathHelper", "testUrlPathHelper"); "mvcUrlPathHelper", "testUrlPathHelper");
} }
@SuppressWarnings("removal")
@Test @Test
void resourceHandlerMappingUsesMvcInfrastructureByDefault() { void resourceHandlerMappingUsesMvcInfrastructureByDefault() {
load(context -> context.registerBean(ResourceHandlerConfiguration.class)); load(context -> context.registerBean(ResourceHandlerConfiguration.class));
@ -106,6 +110,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper")); assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper"));
} }
@SuppressWarnings("removal")
@Test @Test
void resourceHandlerMappingWithPrimaryUsesQualifiedPathMatcher() { void resourceHandlerMappingWithPrimaryUsesQualifiedPathMatcher() {
load(registerPrimaryBean("testPathMatcher", PathMatcher.class) load(registerPrimaryBean("testPathMatcher", PathMatcher.class)
@ -116,6 +121,7 @@ class DelegatingWebMvcConfigurationIntegrationTests {
"mvcPathMatcher", "testPathMatcher"); "mvcPathMatcher", "testPathMatcher");
} }
@SuppressWarnings("removal")
@Test @Test
void resourceHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() { void resourceHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() {
load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class) load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class)

View File

@ -230,15 +230,15 @@ public class DelegatingWebMvcConfigurationTests {
assertThat(resolver.getErrorResponseInterceptors()).containsExactly(interceptor); assertThat(resolver.getErrorResponseInterceptors()).containsExactly(interceptor);
} }
@SuppressWarnings("removal")
@Test @Test
@SuppressWarnings("deprecation")
public void configurePathMatcher() { public void configurePathMatcher() {
PathMatcher pathMatcher = mock(); PathMatcher pathMatcher = mock();
UrlPathHelper pathHelper = mock(); UrlPathHelper pathHelper = mock();
WebMvcConfigurer configurer = new WebMvcConfigurer() { WebMvcConfigurer configurer = new WebMvcConfigurer() {
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public void configurePathMatch(PathMatchConfigurer configurer) { public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUrlPathHelper(pathHelper).setPathMatcher(pathMatcher); configurer.setUrlPathHelper(pathHelper).setPathMatcher(pathMatcher);
} }
@ -293,6 +293,7 @@ public class DelegatingWebMvcConfigurationTests {
configAssertion.accept(webMvcConfig.mvcUrlPathHelper(), webMvcConfig.mvcPathMatcher()); configAssertion.accept(webMvcConfig.mvcUrlPathHelper(), webMvcConfig.mvcPathMatcher());
} }
@SuppressWarnings("removal")
@Test @Test
void configurePathPatternParser() { void configurePathPatternParser() {
PathPatternParser patternParser = new PathPatternParser(); PathPatternParser patternParser = new PathPatternParser();
@ -300,6 +301,7 @@ public class DelegatingWebMvcConfigurationTests {
UrlPathHelper pathHelper = mock(); UrlPathHelper pathHelper = mock();
WebMvcConfigurer configurer = new WebMvcConfigurer() { WebMvcConfigurer configurer = new WebMvcConfigurer() {
@SuppressWarnings("removal")
@Override @Override
public void configurePathMatch(PathMatchConfigurer configurer) { public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setPatternParser(patternParser) configurer.setPatternParser(patternParser)

View File

@ -120,6 +120,7 @@ public class InterceptorRegistryTests {
verifyWebInterceptor(interceptors.get(1), this.webInterceptor2); verifyWebInterceptor(interceptors.get(1), this.webInterceptor2);
} }
@SuppressWarnings("removal")
@Test @Test
void addInterceptorsWithCustomPathMatcher() { void addInterceptorsWithCustomPathMatcher() {
PathMatcher pathMatcher = mock(); PathMatcher pathMatcher = mock();

View File

@ -60,6 +60,7 @@ class ResourceHandlerRegistryTests {
private MockHttpServletResponse response; private MockHttpServletResponse response;
@SuppressWarnings("removal")
@BeforeEach @BeforeEach
void setup() { void setup() {
GenericWebApplicationContext appContext = new GenericWebApplicationContext(); GenericWebApplicationContext appContext = new GenericWebApplicationContext();
@ -202,6 +203,7 @@ class ResourceHandlerRegistryTests {
assertThat(transformers).containsExactly(cachingTransformer, cssLinkTransformer); assertThat(transformers).containsExactly(cachingTransformer, cssLinkTransformer);
} }
@SuppressWarnings("removal")
@Test @Test
void urlResourceWithCharset() { void urlResourceWithCharset() {
this.registration.addResourceLocations("[charset=ISO-8859-1]file:///tmp/"); this.registration.addResourceLocations("[charset=ISO-8859-1]file:///tmp/");

View File

@ -123,6 +123,7 @@ class WebMvcConfigurationSupportExtensionTests {
this.config.setServletContext(this.context.getServletContext()); this.config.setServletContext(this.context.getServletContext());
} }
@SuppressWarnings("removal")
@Test @Test
void handlerMappings() throws Exception { void handlerMappings() throws Exception {
RequestMappingHandlerMapping rmHandlerMapping = this.config.requestMappingHandlerMapping( RequestMappingHandlerMapping rmHandlerMapping = this.config.requestMappingHandlerMapping(
@ -414,6 +415,7 @@ class WebMvcConfigurationSupportExtensionTests {
exceptionResolvers.add(0, new ResponseStatusExceptionResolver()); exceptionResolvers.add(0, new ResponseStatusExceptionResolver());
} }
@SuppressWarnings("removal")
@Override @Override
public void configurePathMatch(PathMatchConfigurer configurer) { public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setPathMatcher(new TestPathMatcher()); configurer.setPathMatcher(new TestPathMatcher());

View File

@ -116,6 +116,7 @@ class BeanNameUrlHandlerMappingTests {
assertThat(hec != null && hec.getHandler() == bean).as("Handler is correct bean").isTrue(); assertThat(hec != null && hec.getHandler() == bean).as("Handler is correct bean").isTrue();
} }
@SuppressWarnings("removal")
@Test @Test
void requestsWithFullPaths() throws Exception { void requestsWithFullPaths() throws Exception {

View File

@ -138,6 +138,7 @@ class HandlerMappingIntrospectorTests {
assertThat(initIntrospector(context).allHandlerMappingsUsePathPatternParser()).isFalse(); assertThat(initIntrospector(context).allHandlerMappingsUsePathPatternParser()).isFalse();
} }
@SuppressWarnings("removal")
@ParameterizedTest @ParameterizedTest
@ValueSource(booleans = {true, false}) @ValueSource(booleans = {true, false})
void getMatchable(boolean usePathPatterns) throws Exception { void getMatchable(boolean usePathPatterns) throws Exception {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -97,6 +97,7 @@ class MappedInterceptorTests {
assertThat(interceptor.matches(requestFactory.apply("/path3/foo/bar/path2"))).isFalse(); assertThat(interceptor.matches(requestFactory.apply("/path3/foo/bar/path2"))).isFalse();
} }
@SuppressWarnings("removal")
@PathPatternsParameterizedTest @PathPatternsParameterizedTest
void customPathMatcher(Function<String, MockHttpServletRequest> requestFactory) { void customPathMatcher(Function<String, MockHttpServletRequest> requestFactory) {
MappedInterceptor interceptor = new MappedInterceptor(new String[] { "/foo/[0-9]*" }, null, delegate); MappedInterceptor interceptor = new MappedInterceptor(new String[] { "/foo/[0-9]*" }, null, delegate);

View File

@ -65,6 +65,7 @@ class SimpleUrlHandlerMappingTests {
.isInstanceOf(NoSuchBeanDefinitionException.class); .isInstanceOf(NoSuchBeanDefinitionException.class);
} }
@SuppressWarnings("removal")
@Test @Test
void newlineInRequestShouldMatch() throws Exception { void newlineInRequestShouldMatch() throws Exception {
Object controller = new Object(); Object controller = new Object();

View File

@ -103,6 +103,7 @@ class WebContentInterceptorTests {
assertThat(cacheControlHeaders).isEmpty(); assertThat(cacheControlHeaders).isEmpty();
} }
@SuppressWarnings("removal")
@Test @Test
void throwsExceptionWithNullPathMatcher() { void throwsExceptionWithNullPathMatcher() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()

View File

@ -30,6 +30,7 @@ import static org.assertj.core.api.InstanceOfAssertFactories.STRING;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
@SuppressWarnings("removal")
class PatternsRequestConditionTests { class PatternsRequestConditionTests {
@Test @Test

View File

@ -75,7 +75,7 @@ import static org.junit.jupiter.api.Named.named;
*/ */
class RequestMappingInfoHandlerMappingTests { class RequestMappingInfoHandlerMappingTests {
@SuppressWarnings("unused") @SuppressWarnings({"unused", "removal"})
static Stream<?> pathPatternsArguments() { static Stream<?> pathPatternsArguments() {
TestController controller = new TestController(); TestController controller = new TestController();
@ -259,7 +259,7 @@ class RequestMappingInfoHandlerMappingTests {
assertThat(chain).isNull(); assertThat(chain).isNull();
} }
@SuppressWarnings("unchecked") @SuppressWarnings({"unchecked", "removal"})
@PathPatternsParameterizedTest @PathPatternsParameterizedTest
void handleMatchUriTemplateVariables(TestRequestMappingInfoHandlerMapping mapping) { void handleMatchUriTemplateVariables(TestRequestMappingInfoHandlerMapping mapping) {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
@ -278,7 +278,7 @@ class RequestMappingInfoHandlerMappingTests {
assertThat(uriVariables.get("path2")).isEqualTo("2"); assertThat(uriVariables.get("path2")).isEqualTo("2");
} }
@SuppressWarnings("unchecked") @SuppressWarnings({"unchecked", "removal"})
@PathPatternsParameterizedTest // SPR-9098 @PathPatternsParameterizedTest // SPR-9098
void handleMatchUriTemplateVariablesDecode(TestRequestMappingInfoHandlerMapping mapping) { void handleMatchUriTemplateVariablesDecode(TestRequestMappingInfoHandlerMapping mapping) {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
@ -302,6 +302,7 @@ class RequestMappingInfoHandlerMappingTests {
assertThat(uriVariables.get("identifier")).isEqualTo("a/b"); assertThat(uriVariables.get("identifier")).isEqualTo("a/b");
} }
@SuppressWarnings("removal")
@PathPatternsParameterizedTest @PathPatternsParameterizedTest
void handleMatchBestMatchingPatternAttribute(TestRequestMappingInfoHandlerMapping mapping) { void handleMatchBestMatchingPatternAttribute(TestRequestMappingInfoHandlerMapping mapping) {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
@ -314,6 +315,7 @@ class RequestMappingInfoHandlerMappingTests {
assertThat(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)).isEqualTo("/{path1}/2"); assertThat(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)).isEqualTo("/{path1}/2");
} }
@SuppressWarnings("removal")
@PathPatternsParameterizedTest @PathPatternsParameterizedTest
void handleMatchBestMatchingPatternAttributeInObservationContext(TestRequestMappingInfoHandlerMapping mapping) { void handleMatchBestMatchingPatternAttributeInObservationContext(TestRequestMappingInfoHandlerMapping mapping) {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
@ -402,6 +404,7 @@ class RequestMappingInfoHandlerMappingTests {
} }
} }
@SuppressWarnings("removal")
@PathPatternsParameterizedTest // SPR-10140, SPR-16867 @PathPatternsParameterizedTest // SPR-10140, SPR-16867
void handleMatchMatrixVariablesDecoding(TestRequestMappingInfoHandlerMapping mapping) { void handleMatchMatrixVariablesDecoding(TestRequestMappingInfoHandlerMapping mapping) {
@ -616,6 +619,7 @@ class RequestMappingInfoHandlerMappingTests {
} }
} }
@SuppressWarnings("removal")
private RequestMappingInfo.BuilderConfiguration getBuilderConfig() { private RequestMappingInfo.BuilderConfiguration getBuilderConfig() {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
if (getPatternParser() != null) { if (getPatternParser() != null) {

View File

@ -48,7 +48,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.HEAD;
*/ */
class RequestMappingInfoTests { class RequestMappingInfoTests {
@SuppressWarnings("unused") @SuppressWarnings({"unused", "removal"})
static Stream<Named<RequestMappingInfo.Builder>> pathPatternsArguments() { static Stream<Named<RequestMappingInfo.Builder>> pathPatternsArguments() {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
config.setPathMatcher(new AntPathMatcher()); config.setPathMatcher(new AntPathMatcher());
@ -59,6 +59,7 @@ class RequestMappingInfoTests {
} }
@SuppressWarnings({"removal", "DataFlowIssue"})
@PathPatternsParameterizedTest @PathPatternsParameterizedTest
void createEmpty(RequestMappingInfo.Builder infoBuilder) { void createEmpty(RequestMappingInfo.Builder infoBuilder) {
@ -92,6 +93,7 @@ class RequestMappingInfoTests {
assertThat(info.getCustomCondition()).isSameAs(result.getCustomCondition()); assertThat(info.getCustomCondition()).isSameAs(result.getCustomCondition());
} }
@SuppressWarnings("removal")
@Test // gh-31662 @Test // gh-31662
void pathPatternByDefault() { void pathPatternByDefault() {
RequestMappingInfo info = RequestMappingInfo.paths().build(); RequestMappingInfo info = RequestMappingInfo.paths().build();
@ -319,6 +321,7 @@ class RequestMappingInfoTests {
assertThat(match).as("Pre-flight should match the ACCESS_CONTROL_REQUEST_METHOD").isNull(); assertThat(match).as("Pre-flight should match the ACCESS_CONTROL_REQUEST_METHOD").isNull();
} }
@SuppressWarnings("removal")
@Test @Test
void mutate() { void mutate() {
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();

View File

@ -593,6 +593,7 @@ class CrossOriginTests {
return AnnotationUtils.findAnnotation(beanType, Controller.class) != null; return AnnotationUtils.findAnnotation(beanType, Controller.class) != null;
} }
@SuppressWarnings("removal")
@Override @Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);

View File

@ -143,6 +143,7 @@ class RequestMappingHandlerMappingTests {
assertThat(info.getActivePatternsCondition().getMatchingCondition(request)).isNull(); assertThat(info.getActivePatternsCondition().getMatchingCondition(request)).isNull();
} }
@SuppressWarnings("removal")
private void initRequestPath(RequestMappingHandlerMapping mapping, MockHttpServletRequest request) { private void initRequestPath(RequestMappingHandlerMapping mapping, MockHttpServletRequest request) {
PathPatternParser parser = mapping.getPatternParser(); PathPatternParser parser = mapping.getPatternParser();
if (parser != null) { if (parser != null) {

View File

@ -149,6 +149,7 @@ class PathResourceResolverTests {
assertThat(path).isNull(); assertThat(path).isNull();
} }
@SuppressWarnings("removal")
@Test @Test
void relativePathEncodedForUrlResource() throws Exception { void relativePathEncodedForUrlResource() throws Exception {
TestUrlResource location = new TestUrlResource("file:///tmp"); TestUrlResource location = new TestUrlResource("file:///tmp");

View File

@ -229,6 +229,7 @@ class ResourceHttpRequestHandlerIntegrationTests {
static class DecodingUrlPathHelperConfig implements WebMvcConfigurer { static class DecodingUrlPathHelperConfig implements WebMvcConfigurer {
@SuppressWarnings("removal")
@Override @Override
public void configurePathMatch(PathMatchConfigurer configurer) { public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper helper = new UrlPathHelper(); UrlPathHelper helper = new UrlPathHelper();
@ -240,6 +241,7 @@ class ResourceHttpRequestHandlerIntegrationTests {
static class NonDecodingUrlPathHelperConfig implements WebMvcConfigurer { static class NonDecodingUrlPathHelperConfig implements WebMvcConfigurer {
@SuppressWarnings("removal")
@Override @Override
public void configurePathMatch(PathMatchConfigurer configurer) { public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper helper = new UrlPathHelper(); UrlPathHelper helper = new UrlPathHelper();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,12 +26,14 @@ import org.jspecify.annotations.Nullable;
import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.PathMatcher;
import org.springframework.web.HttpRequestHandler; import org.springframework.web.HttpRequestHandler;
import org.springframework.web.servlet.handler.AbstractHandlerMapping; import org.springframework.web.servlet.handler.AbstractHandlerMapping;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.WebSocketHandlerMapping; import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* {@link WebSocketHandlerRegistry} with Spring MVC handler mappings for the * {@link WebSocketHandlerRegistry} with Spring MVC handler mappings for the
@ -77,11 +79,16 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
/** /**
* Set the UrlPathHelper to configure on the {@code SimpleUrlHandlerMapping} * Set the UrlPathHelper to configure on the {@code SimpleUrlHandlerMapping}
* used to map handshake requests. * used to map handshake requests.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) { public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }
@Deprecated(since = "7.0", forRemoval = true)
public @Nullable UrlPathHelper getUrlPathHelper() { public @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@ -111,6 +118,7 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
.forEach(registration -> registration.setTaskScheduler(scheduler)); .forEach(registration -> registration.setTaskScheduler(scheduler));
} }
@SuppressWarnings("removal")
public AbstractHandlerMapping getHandlerMapping() { public AbstractHandlerMapping getHandlerMapping() {
Map<String, Object> urlMap = new LinkedHashMap<>(); Map<String, Object> urlMap = new LinkedHashMap<>();
for (ServletWebSocketHandlerRegistration registration : this.registrations) { for (ServletWebSocketHandlerRegistration registration : this.registrations) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,10 @@
package org.springframework.web.socket.config.annotation; package org.springframework.web.socket.config.annotation;
import org.springframework.util.PathMatcher;
import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler; import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* A contract for registering STOMP over WebSocket endpoints. * A contract for registering STOMP over WebSocket endpoints.
@ -42,7 +44,11 @@ public interface StompEndpointRegistry {
/** /**
* Configure a customized {@link UrlPathHelper} for the STOMP endpoint * Configure a customized {@link UrlPathHelper} for the STOMP endpoint
* {@link org.springframework.web.servlet.HandlerMapping HandlerMapping}. * {@link org.springframework.web.servlet.HandlerMapping HandlerMapping}.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@Deprecated(since = "7.0", forRemoval = true)
void setUrlPathHelper(UrlPathHelper urlPathHelper); void setUrlPathHelper(UrlPathHelper urlPathHelper);
/** /**

View File

@ -27,6 +27,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.PathMatcher;
import org.springframework.web.HttpRequestHandler; import org.springframework.web.HttpRequestHandler;
import org.springframework.web.servlet.handler.AbstractHandlerMapping; import org.springframework.web.servlet.handler.AbstractHandlerMapping;
import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketHandler;
@ -36,6 +37,7 @@ import org.springframework.web.socket.messaging.StompSubProtocolHandler;
import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
import org.springframework.web.socket.server.support.WebSocketHandlerMapping; import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
import org.springframework.web.util.pattern.PathPatternParser;
/** /**
* A registry for STOMP over WebSocket endpoints that maps the endpoints with a * A registry for STOMP over WebSocket endpoints that maps the endpoints with a
@ -125,12 +127,18 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
/** /**
* Set the UrlPathHelper to configure on the {@code HandlerMapping} * Set the UrlPathHelper to configure on the {@code HandlerMapping}
* used to map handshake requests. * used to map handshake requests.
* @deprecated use of {@link PathMatcher} and {@link UrlPathHelper} is deprecated
* for use at runtime in web modules in favor of parsed patterns with
* {@link PathPatternParser}.
*/ */
@SuppressWarnings("removal")
@Deprecated(since = "7.0", forRemoval = true)
@Override @Override
public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) { public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) {
this.urlPathHelper = urlPathHelper; this.urlPathHelper = urlPathHelper;
} }
@Deprecated(since = "7.0", forRemoval = true)
protected @Nullable UrlPathHelper getUrlPathHelper() { protected @Nullable UrlPathHelper getUrlPathHelper() {
return this.urlPathHelper; return this.urlPathHelper;
} }
@ -158,6 +166,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
/** /**
* Return a handler mapping with the mapped ViewControllers. * Return a handler mapping with the mapped ViewControllers.
*/ */
@SuppressWarnings("removal")
public AbstractHandlerMapping getHandlerMapping() { public AbstractHandlerMapping getHandlerMapping() {
Map<String, Object> urlMap = new LinkedHashMap<>(); Map<String, Object> urlMap = new LinkedHashMap<>();
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) { for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {

View File

@ -69,6 +69,7 @@ class WebMvcStompEndpointRegistryTests {
assertThat(protocolHandlers.get("v12.stomp")).isNotNull(); assertThat(protocolHandlers.get("v12.stomp")).isNotNull();
} }
@SuppressWarnings("removal")
@Test @Test
void handlerMapping() { void handlerMapping() {
SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.endpointRegistry.getHandlerMapping(); SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.endpointRegistry.getHandlerMapping();