Deprecate config options to match by path extension
See gh-24179
This commit is contained in:
		
							parent
							
								
									54669c51c9
								
							
						
					
					
						commit
						7453c0d0cb
					
				|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2018 the original author or authors. |  * Copyright 2002-2020 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. | ||||||
|  | @ -22,6 +22,7 @@ import java.util.function.Predicate; | ||||||
| 
 | 
 | ||||||
| import org.springframework.lang.Nullable; | import org.springframework.lang.Nullable; | ||||||
| import org.springframework.util.PathMatcher; | import org.springframework.util.PathMatcher; | ||||||
|  | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | ||||||
| import org.springframework.web.util.UrlPathHelper; | import org.springframework.web.util.UrlPathHelper; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -37,7 +38,7 @@ import org.springframework.web.util.UrlPathHelper; | ||||||
|  * |  * | ||||||
|  * @author Brian Clozel |  * @author Brian Clozel | ||||||
|  * @since 4.0.3 |  * @since 4.0.3 | ||||||
|  * @see org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping |  * @see RequestMappingHandlerMapping | ||||||
|  * @see org.springframework.web.servlet.handler.SimpleUrlHandlerMapping |  * @see org.springframework.web.servlet.handler.SimpleUrlHandlerMapping | ||||||
|  */ |  */ | ||||||
| public class PathMatchConfigurer { | public class PathMatchConfigurer { | ||||||
|  | @ -46,10 +47,10 @@ public class PathMatchConfigurer { | ||||||
| 	private Boolean suffixPatternMatch; | 	private Boolean suffixPatternMatch; | ||||||
| 
 | 
 | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	private Boolean trailingSlashMatch; | 	private Boolean registeredSuffixPatternMatch; | ||||||
| 
 | 
 | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	private Boolean registeredSuffixPatternMatch; | 	private Boolean trailingSlashMatch; | ||||||
| 
 | 
 | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	private UrlPathHelper urlPathHelper; | 	private UrlPathHelper urlPathHelper; | ||||||
|  | @ -66,22 +67,16 @@ public class PathMatchConfigurer { | ||||||
| 	 * requests. If enabled a method mapped to "/users" also matches to "/users.*". | 	 * requests. If enabled a method mapped to "/users" also matches to "/users.*". | ||||||
| 	 * <p>By default this is set to {@code true}. | 	 * <p>By default this is set to {@code true}. | ||||||
| 	 * @see #registeredSuffixPatternMatch | 	 * @see #registeredSuffixPatternMatch | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch) { | 	public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch) { | ||||||
| 		this.suffixPatternMatch = suffixPatternMatch; | 		this.suffixPatternMatch = suffixPatternMatch; | ||||||
| 		return this; | 		return this; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** |  | ||||||
| 	 * Whether to match to URLs irrespective of the presence of a trailing slash. |  | ||||||
| 	 * If enabled a method mapped to "/users" also matches to "/users/". |  | ||||||
| 	 * <p>The default value is {@code true}. |  | ||||||
| 	 */ |  | ||||||
| 	public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) { |  | ||||||
| 		this.trailingSlashMatch = trailingSlashMatch; |  | ||||||
| 		return this; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Whether suffix pattern matching should work only against path extensions | 	 * Whether suffix pattern matching should work only against path extensions | ||||||
| 	 * explicitly registered when you | 	 * explicitly registered when you | ||||||
|  | @ -90,12 +85,26 @@ public class PathMatchConfigurer { | ||||||
| 	 * avoid issues such as when a "." appears in the path for other reasons. | 	 * avoid issues such as when a "." appears in the path for other reasons. | ||||||
| 	 * <p>By default this is set to "false". | 	 * <p>By default this is set to "false". | ||||||
| 	 * @see WebMvcConfigurer#configureContentNegotiation | 	 * @see WebMvcConfigurer#configureContentNegotiation | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch) { | 	public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch) { | ||||||
| 		this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; | 		this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; | ||||||
| 		return this; | 		return this; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Whether to match to URLs irrespective of the presence of a trailing slash. | ||||||
|  | 	 * If enabled a method mapped to "/users" also matches to "/users/". | ||||||
|  | 	 * <p>The default value is {@code true}. | ||||||
|  | 	 */ | ||||||
|  | 	public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) { | ||||||
|  | 		this.trailingSlashMatch = trailingSlashMatch; | ||||||
|  | 		return this; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Set the UrlPathHelper to use for resolution of lookup paths. | 	 * Set the UrlPathHelper to use for resolution of lookup paths. | ||||||
| 	 * <p>Use this to override the default UrlPathHelper with a custom subclass, | 	 * <p>Use this to override the default UrlPathHelper with a custom subclass, | ||||||
|  | @ -137,21 +146,35 @@ public class PathMatchConfigurer { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Whether to use registered suffixes for pattern matching. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
|  | 	 */ | ||||||
| 	@Nullable | 	@Nullable | ||||||
|  | 	@Deprecated | ||||||
| 	public Boolean isUseSuffixPatternMatch() { | 	public Boolean isUseSuffixPatternMatch() { | ||||||
| 		return this.suffixPatternMatch; | 		return this.suffixPatternMatch; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Whether to use registered suffixes for pattern matching. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
|  | 	 */ | ||||||
|  | 	@Nullable | ||||||
|  | 	@Deprecated | ||||||
|  | 	public Boolean isUseRegisteredSuffixPatternMatch() { | ||||||
|  | 		return this.registeredSuffixPatternMatch; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	public Boolean isUseTrailingSlashMatch() { | 	public Boolean isUseTrailingSlashMatch() { | ||||||
| 		return this.trailingSlashMatch; | 		return this.trailingSlashMatch; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Nullable |  | ||||||
| 	public Boolean isUseRegisteredSuffixPatternMatch() { |  | ||||||
| 		return this.registeredSuffixPatternMatch; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@Nullable | 	@Nullable | ||||||
| 	public UrlPathHelper getUrlPathHelper() { | 	public UrlPathHelper getUrlPathHelper() { | ||||||
| 		return this.urlPathHelper; | 		return this.urlPathHelper; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2019 the original author or authors. |  * Copyright 2002-2020 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. | ||||||
|  | @ -275,6 +275,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv | ||||||
| 	 * requests to annotated controllers. | 	 * requests to annotated controllers. | ||||||
| 	 */ | 	 */ | ||||||
| 	@Bean | 	@Bean | ||||||
|  | 	@SuppressWarnings("deprecation") | ||||||
| 	public RequestMappingHandlerMapping requestMappingHandlerMapping( | 	public RequestMappingHandlerMapping requestMappingHandlerMapping( | ||||||
| 			@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, | 			@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, | ||||||
| 			@Qualifier("mvcConversionService") FormattingConversionService conversionService, | 			@Qualifier("mvcConversionService") FormattingConversionService conversionService, | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2019 the original author or authors. |  * Copyright 2002-2020 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. | ||||||
|  | @ -33,6 +33,7 @@ import org.springframework.util.AntPathMatcher; | ||||||
| import org.springframework.util.PathMatcher; | import org.springframework.util.PathMatcher; | ||||||
| import org.springframework.util.StringUtils; | import org.springframework.util.StringUtils; | ||||||
| import org.springframework.web.servlet.HandlerMapping; | import org.springframework.web.servlet.HandlerMapping; | ||||||
|  | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | ||||||
| import org.springframework.web.util.UrlPathHelper; | import org.springframework.web.util.UrlPathHelper; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -58,23 +59,42 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Creates a new instance with the given URL patterns. | 	 * Creates a new instance with the given URL patterns. Each pattern that is | ||||||
| 	 * Each pattern that is not empty and does not start with "/" is prepended with "/". | 	 * not empty and does not start with "/" is prepended with "/". | ||||||
| 	 * @param patterns 0 or more URL patterns; if 0 the condition will match to every request. | 	 * @param patterns 0 or more URL patterns; if 0 the condition will match to | ||||||
|  | 	 * every request. | ||||||
| 	 */ | 	 */ | ||||||
| 	public PatternsRequestCondition(String... patterns) { | 	public PatternsRequestCondition(String... patterns) { | ||||||
| 		this(Arrays.asList(patterns), null, null, true, true, null); | 		this(Arrays.asList(patterns), null, null, true, true, null); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Additional constructor with flags for using suffix pattern (.*) and | 	 * Alternative constructor with additional, optional {@link UrlPathHelper}, | ||||||
| 	 * trailing slash matches. | 	 * {@link PathMatcher}, and whether to automatically match trailing slashes. | ||||||
|  | 	 * @param patterns the URL patterns to use; if 0, the condition will match to every request. | ||||||
|  | 	 * @param urlPathHelper a {@link UrlPathHelper} for determining the lookup path for a request | ||||||
|  | 	 * @param pathMatcher a {@link PathMatcher} for pattern path matching | ||||||
|  | 	 * @param useTrailingSlashMatch whether to match irrespective of a trailing slash | ||||||
|  | 	 * @since 5.2.4 | ||||||
|  | 	 */ | ||||||
|  | 	public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper, | ||||||
|  | 			@Nullable PathMatcher pathMatcher, boolean useTrailingSlashMatch) { | ||||||
|  | 
 | ||||||
|  | 		this(Arrays.asList(patterns), urlPathHelper, pathMatcher, false, useTrailingSlashMatch, null); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Alternative constructor with additional optional parameters. | ||||||
| 	 * @param patterns the URL patterns to use; if 0, the condition will match to every request. | 	 * @param patterns the URL patterns to use; if 0, the condition will match to every request. | ||||||
| 	 * @param urlPathHelper for determining the lookup path of a request | 	 * @param urlPathHelper for determining the lookup path of a request | ||||||
| 	 * @param pathMatcher for path matching with patterns | 	 * @param pathMatcher for path matching with patterns | ||||||
| 	 * @param useSuffixPatternMatch whether to enable matching by suffix (".*") | 	 * @param useSuffixPatternMatch whether to enable matching by suffix (".*") | ||||||
| 	 * @param useTrailingSlashMatch whether to match irrespective of a trailing slash | 	 * @param useTrailingSlashMatch whether to match irrespective of a trailing slash | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper, | 	public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper, | ||||||
| 			@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch) { | 			@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch) { | ||||||
| 
 | 
 | ||||||
|  | @ -82,15 +102,18 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Creates a new instance with the given URL patterns. | 	 * Alternative constructor with additional optional parameters. | ||||||
| 	 * Each pattern that is not empty and does not start with "/" is pre-pended with "/". |  | ||||||
| 	 * @param patterns the URL patterns to use; if 0, the condition will match to every request. | 	 * @param patterns the URL patterns to use; if 0, the condition will match to every request. | ||||||
| 	 * @param urlPathHelper a {@link UrlPathHelper} for determining the lookup path for a request | 	 * @param urlPathHelper a {@link UrlPathHelper} for determining the lookup path for a request | ||||||
| 	 * @param pathMatcher a {@link PathMatcher} for pattern path matching | 	 * @param pathMatcher a {@link PathMatcher} for pattern path matching | ||||||
| 	 * @param useSuffixPatternMatch whether to enable matching by suffix (".*") | 	 * @param useSuffixPatternMatch whether to enable matching by suffix (".*") | ||||||
| 	 * @param useTrailingSlashMatch whether to match irrespective of a trailing slash | 	 * @param useTrailingSlashMatch whether to match irrespective of a trailing slash | ||||||
| 	 * @param fileExtensions a list of file extensions to consider for path matching | 	 * @param fileExtensions a list of file extensions to consider for path matching | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 	 * {@link RequestMappingHandlerMapping} on the deprecation of path extension | ||||||
|  | 	 * config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper, | 	public PatternsRequestCondition(String[] patterns, @Nullable UrlPathHelper urlPathHelper, | ||||||
| 			@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch, | 			@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch, | ||||||
| 			boolean useTrailingSlashMatch, @Nullable List<String> fileExtensions) { | 			boolean useTrailingSlashMatch, @Nullable List<String> fileExtensions) { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2019 the original author or authors. |  * Copyright 2002-2020 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. | ||||||
|  | @ -35,6 +35,7 @@ import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition; | ||||||
| import org.springframework.web.servlet.mvc.condition.RequestCondition; | import org.springframework.web.servlet.mvc.condition.RequestCondition; | ||||||
| import org.springframework.web.servlet.mvc.condition.RequestConditionHolder; | import org.springframework.web.servlet.mvc.condition.RequestConditionHolder; | ||||||
| import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; | import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; | ||||||
|  | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | ||||||
| import org.springframework.web.util.UrlPathHelper; | import org.springframework.web.util.UrlPathHelper; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -505,6 +506,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | 		@SuppressWarnings("deprecation") | ||||||
| 		public RequestMappingInfo build() { | 		public RequestMappingInfo build() { | ||||||
| 			ContentNegotiationManager manager = this.options.getContentNegotiationManager(); | 			ContentNegotiationManager manager = this.options.getContentNegotiationManager(); | ||||||
| 
 | 
 | ||||||
|  | @ -600,14 +602,22 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping | ||||||
| 		 * Set whether to apply suffix pattern matching in PatternsRequestCondition. | 		 * Set whether to apply suffix pattern matching in PatternsRequestCondition. | ||||||
| 		 * <p>By default this is set to 'true'. | 		 * <p>By default this is set to 'true'. | ||||||
| 		 * @see #setRegisteredSuffixPatternMatch(boolean) | 		 * @see #setRegisteredSuffixPatternMatch(boolean) | ||||||
|  | 		 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 		 * {@link RequestMappingHandlerMapping} on the deprecation of path | ||||||
|  | 		 * extension config options. | ||||||
| 		 */ | 		 */ | ||||||
|  | 		@Deprecated | ||||||
| 		public void setSuffixPatternMatch(boolean suffixPatternMatch) { | 		public void setSuffixPatternMatch(boolean suffixPatternMatch) { | ||||||
| 			this.suffixPatternMatch = suffixPatternMatch; | 			this.suffixPatternMatch = suffixPatternMatch; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/** | 		/** | ||||||
| 		 * Return whether to apply suffix pattern matching in PatternsRequestCondition. | 		 * Return whether to apply suffix pattern matching in PatternsRequestCondition. | ||||||
|  | 		 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 		 * {@link RequestMappingHandlerMapping} on the deprecation of path | ||||||
|  | 		 * extension config options. | ||||||
| 		 */ | 		 */ | ||||||
|  | 		@Deprecated | ||||||
| 		public boolean useSuffixPatternMatch() { | 		public boolean useSuffixPatternMatch() { | ||||||
| 			return this.suffixPatternMatch; | 			return this.suffixPatternMatch; | ||||||
| 		} | 		} | ||||||
|  | @ -618,7 +628,12 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping | ||||||
| 		 * {@code suffixPatternMatch=true} and requires that a | 		 * {@code suffixPatternMatch=true} and requires that a | ||||||
| 		 * {@link #setContentNegotiationManager} is also configured in order to | 		 * {@link #setContentNegotiationManager} is also configured in order to | ||||||
| 		 * obtain the registered file extensions. | 		 * obtain the registered file extensions. | ||||||
|  | 		 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 		 * {@link RequestMappingHandlerMapping} on the deprecation of path | ||||||
|  | 		 * extension config options; note also that in 5.3 the default for this | ||||||
|  | 		 * property switches from {@code false} to {@code true}. | ||||||
| 		 */ | 		 */ | ||||||
|  | 		@Deprecated | ||||||
| 		public void setRegisteredSuffixPatternMatch(boolean registeredSuffixPatternMatch) { | 		public void setRegisteredSuffixPatternMatch(boolean registeredSuffixPatternMatch) { | ||||||
| 			this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; | 			this.registeredSuffixPatternMatch = registeredSuffixPatternMatch; | ||||||
| 			this.suffixPatternMatch = (registeredSuffixPatternMatch || this.suffixPatternMatch); | 			this.suffixPatternMatch = (registeredSuffixPatternMatch || this.suffixPatternMatch); | ||||||
|  | @ -627,7 +642,11 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping | ||||||
| 		/** | 		/** | ||||||
| 		 * Return whether suffix pattern matching should be restricted to registered | 		 * Return whether suffix pattern matching should be restricted to registered | ||||||
| 		 * file extensions only. | 		 * file extensions only. | ||||||
|  | 		 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 		 * {@link RequestMappingHandlerMapping} on the deprecation of path | ||||||
|  | 		 * extension config options. | ||||||
| 		 */ | 		 */ | ||||||
|  | 		@Deprecated | ||||||
| 		public boolean useRegisteredSuffixPatternMatch() { | 		public boolean useRegisteredSuffixPatternMatch() { | ||||||
| 			return this.registeredSuffixPatternMatch; | 			return this.registeredSuffixPatternMatch; | ||||||
| 		} | 		} | ||||||
|  | @ -636,8 +655,12 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping | ||||||
| 		 * Return the file extensions to use for suffix pattern matching. If | 		 * Return the file extensions to use for suffix pattern matching. If | ||||||
| 		 * {@code registeredSuffixPatternMatch=true}, the extensions are obtained | 		 * {@code registeredSuffixPatternMatch=true}, the extensions are obtained | ||||||
| 		 * from the configured {@code contentNegotiationManager}. | 		 * from the configured {@code contentNegotiationManager}. | ||||||
|  | 		 * @deprecated as of 5.2.4. See class-level note in | ||||||
|  | 		 * {@link RequestMappingHandlerMapping} on the deprecation of path | ||||||
|  | 		 * extension config options. | ||||||
| 		 */ | 		 */ | ||||||
| 		@Nullable | 		@Nullable | ||||||
|  | 		@Deprecated | ||||||
| 		public List<String> getFileExtensions() { | 		public List<String> getFileExtensions() { | ||||||
| 			if (useRegisteredSuffixPatternMatch() && this.contentNegotiationManager != null) { | 			if (useRegisteredSuffixPatternMatch() && this.contentNegotiationManager != null) { | ||||||
| 				return this.contentNegotiationManager.getAllFileExtensions(); | 				return this.contentNegotiationManager.getAllFileExtensions(); | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2002-2019 the original author or authors. |  * Copyright 2002-2020 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. | ||||||
|  | @ -59,6 +59,18 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMappi | ||||||
|  * {@link RequestMapping @RequestMapping} annotations in |  * {@link RequestMapping @RequestMapping} annotations in | ||||||
|  * {@link Controller @Controller} classes. |  * {@link Controller @Controller} classes. | ||||||
|  * |  * | ||||||
|  |  * <p><strong>Note:</strong></p> In 5.2.4, | ||||||
|  |  * {@link #setUseSuffixPatternMatch(boolean) useSuffixPatternMatch} and | ||||||
|  |  * {@link #setUseRegisteredSuffixPatternMatch(boolean) useRegisteredSuffixPatternMatch} | ||||||
|  |  * are deprecated in order to discourage use of path extensions for request | ||||||
|  |  * mapping and for content negotiation (with similar deprecations in | ||||||
|  |  * {@link ContentNegotiationManager}). For further context, please read issue | ||||||
|  |  * <a href="https://github.com/spring-projects/spring-framework/issues/24179">#24719</a>. | ||||||
|  |  * | ||||||
|  |  * <p>In 5.3, {@link #setUseRegisteredSuffixPatternMatch(boolean) useRegisteredSuffixPatternMatch} | ||||||
|  |  * switches to being on by default so that path matching becomes constrained | ||||||
|  |  * to registered suffixes only. | ||||||
|  |  * | ||||||
|  * @author Arjen Poutsma |  * @author Arjen Poutsma | ||||||
|  * @author Rossen Stoyanchev |  * @author Rossen Stoyanchev | ||||||
|  * @author Sam Brannen |  * @author Sam Brannen | ||||||
|  | @ -89,7 +101,10 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi | ||||||
| 	 * <p>The default value is {@code true}. | 	 * <p>The default value is {@code true}. | ||||||
| 	 * <p>Also see {@link #setUseRegisteredSuffixPatternMatch(boolean)} for | 	 * <p>Also see {@link #setUseRegisteredSuffixPatternMatch(boolean)} for | ||||||
| 	 * more fine-grained control over specific suffixes to allow. | 	 * more fine-grained control over specific suffixes to allow. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class level comment about deprecation of | ||||||
|  | 	 * path extension config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) { | 	public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) { | ||||||
| 		this.useSuffixPatternMatch = useSuffixPatternMatch; | 		this.useSuffixPatternMatch = useSuffixPatternMatch; | ||||||
| 	} | 	} | ||||||
|  | @ -100,7 +115,11 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi | ||||||
| 	 * is generally recommended to reduce ambiguity and to avoid issues such as | 	 * is generally recommended to reduce ambiguity and to avoid issues such as | ||||||
| 	 * when a "." appears in the path for other reasons. | 	 * when a "." appears in the path for other reasons. | ||||||
| 	 * <p>By default this is set to "false". | 	 * <p>By default this is set to "false". | ||||||
|  | 	 * @deprecated as of 5.2.4. See class level comment about deprecation of | ||||||
|  | 	 * path extension config options note also that in 5.3 the default for this | ||||||
|  | 	 * property will switch from {@code false} to {@code true}. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public void setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch) { | 	public void setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch) { | ||||||
| 		this.useRegisteredSuffixPatternMatch = useRegisteredSuffixPatternMatch; | 		this.useRegisteredSuffixPatternMatch = useRegisteredSuffixPatternMatch; | ||||||
| 		this.useSuffixPatternMatch = (useRegisteredSuffixPatternMatch || this.useSuffixPatternMatch); | 		this.useSuffixPatternMatch = (useRegisteredSuffixPatternMatch || this.useSuffixPatternMatch); | ||||||
|  | @ -159,13 +178,14 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  | 	@SuppressWarnings("deprecation") | ||||||
| 	public void afterPropertiesSet() { | 	public void afterPropertiesSet() { | ||||||
| 		this.config = new RequestMappingInfo.BuilderConfiguration(); | 		this.config = new RequestMappingInfo.BuilderConfiguration(); | ||||||
| 		this.config.setUrlPathHelper(getUrlPathHelper()); | 		this.config.setUrlPathHelper(getUrlPathHelper()); | ||||||
| 		this.config.setPathMatcher(getPathMatcher()); | 		this.config.setPathMatcher(getPathMatcher()); | ||||||
| 		this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); | 		this.config.setSuffixPatternMatch(useSuffixPatternMatch()); | ||||||
| 		this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); | 		this.config.setTrailingSlashMatch(useTrailingSlashMatch()); | ||||||
| 		this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); | 		this.config.setRegisteredSuffixPatternMatch(useRegisteredSuffixPatternMatch()); | ||||||
| 		this.config.setContentNegotiationManager(getContentNegotiationManager()); | 		this.config.setContentNegotiationManager(getContentNegotiationManager()); | ||||||
| 
 | 
 | ||||||
| 		super.afterPropertiesSet(); | 		super.afterPropertiesSet(); | ||||||
|  | @ -173,15 +193,21 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Whether to use suffix pattern matching. | 	 * Whether to use registered suffixes for pattern matching. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note on the deprecation of path | ||||||
|  | 	 * extension config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public boolean useSuffixPatternMatch() { | 	public boolean useSuffixPatternMatch() { | ||||||
| 		return this.useSuffixPatternMatch; | 		return this.useSuffixPatternMatch; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Whether to use registered suffixes for pattern matching. | 	 * Whether to use registered suffixes for pattern matching. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note on the deprecation of path | ||||||
|  | 	 * extension config options. | ||||||
| 	 */ | 	 */ | ||||||
|  | 	@Deprecated | ||||||
| 	public boolean useRegisteredSuffixPatternMatch() { | 	public boolean useRegisteredSuffixPatternMatch() { | ||||||
| 		return this.useRegisteredSuffixPatternMatch; | 		return this.useRegisteredSuffixPatternMatch; | ||||||
| 	} | 	} | ||||||
|  | @ -195,8 +221,12 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Return the file extensions to use for suffix pattern matching. | 	 * Return the file extensions to use for suffix pattern matching. | ||||||
|  | 	 * @deprecated as of 5.2.4. See class-level note on the deprecation of path | ||||||
|  | 	 * extension config options. | ||||||
| 	 */ | 	 */ | ||||||
| 	@Nullable | 	@Nullable | ||||||
|  | 	@Deprecated | ||||||
|  | 	@SuppressWarnings("deprecation") | ||||||
| 	public List<String> getFileExtensions() { | 	public List<String> getFileExtensions() { | ||||||
| 		return this.config.getFileExtensions(); | 		return this.config.getFileExtensions(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue