diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java index 0ea1923820..0e2fba2adf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,14 +60,6 @@ class CompositeHandlerAdapter implements HandlerAdapter { return null; } - @Override - @Deprecated(since = "2.4.9", forRemoval = false) - @SuppressWarnings("deprecation") - public long getLastModified(HttpServletRequest request, Object handler) { - Optional adapter = getAdapter(handler); - return adapter.map((handlerAdapter) -> handlerAdapter.getLastModified(request, handler)).orElse(0L); - } - private Optional getAdapter(Object handler) { if (this.adapters == null) { this.adapters = extractAdapters(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java index 1e8b337ab2..5a4cd188ee 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java @@ -249,11 +249,6 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin return null; } - @Override - protected void extendInterceptors(List interceptors) { - interceptors.add(new SkipPathExtensionContentNegotiation()); - } - /** * Return the Handler providing actuator links at the root endpoint. * @return the links handler diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMapping.java index 267614cdf7..ad246c0d88 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMapping.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.Set; @@ -163,9 +162,4 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi return this.corsConfiguration; } - @Override - protected void extendInterceptors(List interceptors) { - interceptors.add(new SkipPathExtensionContentNegotiation()); - } - } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/SkipPathExtensionContentNegotiation.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/SkipPathExtensionContentNegotiation.java deleted file mode 100644 index d60e5abddc..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/SkipPathExtensionContentNegotiation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.endpoint.web.servlet; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.web.servlet.HandlerInterceptor; - -/** - * {@link HandlerInterceptor} to ensure that - * {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} is - * skipped for web endpoints. - * - * @author Phillip Webb - */ -final class SkipPathExtensionContentNegotiation implements HandlerInterceptor { - - @SuppressWarnings("deprecation") - private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class - .getName() + ".SKIP"; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - request.setAttribute(SKIP_ATTRIBUTE, Boolean.TRUE); - return true; - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java index 131a9c7d55..1caf98e9ca 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,6 +70,7 @@ public class RequestMappingConditionsDescription { .toList(); } + @SuppressWarnings("removal") private Set extractPathPatterns(RequestMappingInfo requestMapping) { PatternsRequestCondition patternsCondition = requestMapping.getPatternsCondition(); return (patternsCondition != null) ? patternsCondition.getPatterns() diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index 89291825ed..909f028f84 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet; import java.time.Duration; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.function.Consumer; @@ -80,13 +79,9 @@ import org.springframework.util.CollectionUtils; import org.springframework.validation.DefaultMessageCodesResolver; import org.springframework.validation.MessageCodesResolver; import org.springframework.validation.Validator; -import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.accept.ContentNegotiationManager; -import org.springframework.web.accept.ContentNegotiationStrategy; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.context.ServletContextAware; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextListener; import org.springframework.web.context.support.ServletContextResource; import org.springframework.web.filter.FormContentFilter; @@ -459,15 +454,6 @@ public class WebMvcAutoConfiguration { return localeResolver; } - @Override - @Bean - @ConditionalOnMissingBean(name = DispatcherServlet.THEME_RESOLVER_BEAN_NAME) - @Deprecated(since = "3.0.0", forRemoval = false) - @SuppressWarnings("deprecation") - public org.springframework.web.servlet.ThemeResolver themeResolver() { - return super.themeResolver(); - } - @Override @Bean @ConditionalOnMissingBean(name = DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME) @@ -580,22 +566,6 @@ public class WebMvcAutoConfiguration { } } - @Bean - @Override - @SuppressWarnings("deprecation") - public ContentNegotiationManager mvcContentNegotiationManager() { - ContentNegotiationManager manager = super.mvcContentNegotiationManager(); - List strategies = manager.getStrategies(); - ListIterator iterator = strategies.listIterator(); - while (iterator.hasNext()) { - ContentNegotiationStrategy strategy = iterator.next(); - if (strategy instanceof org.springframework.web.accept.PathExtensionContentNegotiationStrategy) { - iterator.set(new OptionalPathExtensionContentNegotiationStrategy(strategy)); - } - } - return manager; - } - @Override public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; @@ -683,33 +653,4 @@ public class WebMvcAutoConfiguration { } - /** - * Decorator to make - * {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} - * optional depending on a request attribute. - */ - static class OptionalPathExtensionContentNegotiationStrategy implements ContentNegotiationStrategy { - - @SuppressWarnings("deprecation") - private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class - .getName() + ".SKIP"; - - private final ContentNegotiationStrategy delegate; - - OptionalPathExtensionContentNegotiationStrategy(ContentNegotiationStrategy delegate) { - this.delegate = delegate; - } - - @Override - public List resolveMediaTypes(NativeWebRequest webRequest) - throws HttpMediaTypeNotAcceptableException { - Object skip = webRequest.getAttribute(SKIP_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); - if (skip != null && Boolean.parseBoolean(skip.toString())) { - return MEDIA_TYPE_ALL_LIST; - } - return this.delegate.resolveMediaTypes(webRequest); - } - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java index 86995cb0be..96a4a5bc25 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java @@ -158,15 +158,6 @@ class DispatcherServletAutoConfigurationTests { }); } - @Test - @Deprecated(since = "3.2.0", forRemoval = true) - void dispatcherServletThrowExceptionIfNoHandlerFoundDefaultConfig() { - this.contextRunner.run((context) -> { - DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class); - assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(true); - }); - } - @Test void dispatcherServletCustomConfig() { this.contextRunner diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index f6a2956a06..44e0c9d318 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -110,7 +110,6 @@ import org.springframework.web.servlet.RequestToViewNameTranslator; import org.springframework.web.servlet.View; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer; -import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -865,16 +864,6 @@ class WebMvcAutoConfigurationTests { }); } - @Test - void defaultContentNegotiation() { - this.contextRunner.run((context) -> { - RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class); - ContentNegotiationManager contentNegotiationManager = handlerMapping.getContentNegotiationManager(); - assertThat(contentNegotiationManager.getStrategies()).doesNotHaveAnyElementsOfTypes( - WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy.class); - }); - } - @Test void queryParameterContentNegotiation() { this.contextRunner.withPropertyValues("spring.mvc.contentnegotiation.favor-parameter:true").run((context) -> { @@ -885,16 +874,6 @@ class WebMvcAutoConfigurationTests { }); } - @Test - void customConfigurerAppliedAfterAutoConfig() { - this.contextRunner.withUserConfiguration(CustomConfigurer.class).run((context) -> { - ContentNegotiationManager manager = context.getBean(ContentNegotiationManager.class); - assertThat(manager.getStrategies()) - .anyMatch((strategy) -> WebMvcAutoConfiguration.OptionalPathExtensionContentNegotiationStrategy.class - .isAssignableFrom(strategy.getClass())); - }); - } - @Test void requestContextFilterIsAutoConfigured() { this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RequestContextFilter.class)); @@ -1324,17 +1303,6 @@ class WebMvcAutoConfigurationTests { } - @Configuration(proxyBeanMethods = false) - static class CustomConfigurer implements WebMvcConfigurer { - - @Override - @SuppressWarnings("deprecation") - public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { - configurer.favorPathExtension(true); - } - - } - @Configuration(proxyBeanMethods = false) static class CustomApplicationTaskExecutorConfig {