diff --git a/spring-web/src/main/java/org/springframework/http/HttpStatus.java b/spring-web/src/main/java/org/springframework/http/HttpStatus.java index b29deb1414e6..0c6587162d4e 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpStatus.java +++ b/spring-web/src/main/java/org/springframework/http/HttpStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,14 +56,6 @@ public enum HttpStatus implements HttpStatusCode { * @since 6.0.5 */ EARLY_HINTS(103, Series.INFORMATIONAL, "Early Hints"), - /** - * {@code 103 Checkpoint}. - * @see A proposal for supporting - * resumable POST/PUT HTTP requests in HTTP/1.0 - * @deprecated in favor of {@link #EARLY_HINTS} which will be returned from {@code HttpStatus.valueOf(103)} - */ - @Deprecated(since = "6.0.5") - CHECKPOINT(103, Series.INFORMATIONAL, "Checkpoint"), // 2xx Success diff --git a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java index e068c9e0da49..445cda5a21e0 100644 --- a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java +++ b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -183,18 +183,6 @@ public HttpStatusCode getStatusCode() { return this.status; } - /** - * Return the HTTP status code of the response. - * @return the HTTP status as an int value - * @since 4.3 - * @deprecated as of 6.0, in favor of {@link #getStatusCode()}; scheduled - * for removal in 7.0 - */ - @Deprecated(since = "6.0") - public int getStatusCodeValue() { - return getStatusCode().value(); - } - @Override public boolean equals(@Nullable Object other) { diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java deleted file mode 100644 index fdda1a963291..000000000000 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorResourceFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2002-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.http.client.reactive; - -import reactor.netty.resources.ConnectionProvider; -import reactor.netty.resources.LoopResources; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.Lifecycle; - -/** - * Factory to manage Reactor Netty resources, i.e. {@link LoopResources} for - * event loop threads, and {@link ConnectionProvider} for the connection pool, - * within the lifecycle of a Spring {@code ApplicationContext}. - * - *

This factory implements {@link InitializingBean}, {@link DisposableBean} - * and {@link Lifecycle} and is expected typically to be declared as a - * Spring-managed bean. - * - *

Notice that after a {@link Lifecycle} stop/restart, new instances of - * the configured {@link LoopResources} and {@link ConnectionProvider} are - * created, so any references to those should be updated. - * - * @author Rossen Stoyanchev - * @author Brian Clozel - * @author Sebastien Deleuze - * @since 5.1 - * @deprecated since 6.1 due to a package change; use {@link org.springframework.http.client.ReactorResourceFactory} instead. - */ -@Deprecated(since = "6.1") -public class ReactorResourceFactory extends org.springframework.http.client.ReactorResourceFactory { -} diff --git a/spring-web/src/main/java/org/springframework/web/client/UnknownContentTypeException.java b/spring-web/src/main/java/org/springframework/web/client/UnknownContentTypeException.java index 89785e0fe2a5..ce3c84e7814c 100644 --- a/spring-web/src/main/java/org/springframework/web/client/UnknownContentTypeException.java +++ b/spring-web/src/main/java/org/springframework/web/client/UnknownContentTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,15 +112,6 @@ public HttpStatusCode getStatusCode() { return this.statusCode; } - /** - * Return the raw HTTP status code value. - * @deprecated in favor of {@link #getStatusCode()}, for removal in 7.0 - */ - @Deprecated(since = "6.0") - public int getRawStatusCode() { - return this.statusCode.value(); - } - /** * Return the HTTP status text. */ diff --git a/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java b/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java index bf07e9c9a057..6f8b05090a0a 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,8 +50,6 @@ */ public class ModelAndViewContainer { - private boolean ignoreDefaultModelOnRedirect = true; - private @Nullable Object view; private final ModelMap defaultModel = new BindingAwareModelMap(); @@ -71,25 +69,6 @@ public class ModelAndViewContainer { private boolean requestHandled = false; - /** - * By default, the content of the "default" model is used both during - * rendering and redirect scenarios. Alternatively controller methods - * can declare an argument of type {@code RedirectAttributes} and use - * it to provide attributes to prepare the redirect URL. - *

Setting this flag to {@code true} guarantees the "default" model is - * never used in a redirect scenario even if a RedirectAttributes argument - * is not declared. Setting it to {@code false} means the "default" model - * may be used in a redirect if the controller method doesn't declare a - * RedirectAttributes argument. - *

As of 6.0, this property is set to {@code true} by default. - * @deprecated as of 6.0 without a replacement; once removed, the default - * model will always be ignored on redirect - */ - @Deprecated(since = "6.0") - public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect) { - this.ignoreDefaultModelOnRedirect = ignoreDefaultModelOnRedirect; - } - /** * Set a view name to be resolved by the DispatcherServlet via a ViewResolver. * Will override any pre-existing view name or View. @@ -137,22 +116,13 @@ public boolean isViewReference() { * a method argument) and {@code ignoreDefaultModelOnRedirect=false}. */ public ModelMap getModel() { - if (useDefaultModel()) { + if (!this.redirectModelScenario) { return this.defaultModel; } - else { - if (this.redirectModel == null) { - this.redirectModel = new ModelMap(); - } - return this.redirectModel; + if (this.redirectModel == null) { + this.redirectModel = new ModelMap(); } - } - - /** - * Whether to use the default model or the redirect model. - */ - private boolean useDefaultModel() { - return (!this.redirectModelScenario || (this.redirectModel == null && !this.ignoreDefaultModelOnRedirect)); + return this.redirectModel; } /** @@ -336,7 +306,7 @@ public String toString() { else { sb.append("View is [").append(this.view).append(']'); } - if (useDefaultModel()) { + if (!this.redirectModelScenario) { sb.append("; default model "); } else { diff --git a/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java b/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java deleted file mode 100644 index c334afca5cc7..000000000000 --- a/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2002-2022 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.web.util; - -import jakarta.servlet.http.Cookie; -import jakarta.servlet.http.HttpServletResponse; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jspecify.annotations.Nullable; - -import org.springframework.util.Assert; - -/** - * Helper class for cookie generation, carrying cookie descriptor settings - * as bean properties and being able to add and remove cookie to/from a - * given response. - * - *

Can serve as base class for components that generate specific cookies. - * - * @author Juergen Hoeller - * @since 1.1.4 - * @see #addCookie - * @see #removeCookie - * @deprecated as of 6.0 in favor of {@link org.springframework.http.ResponseCookie} for removal in 7.1 - */ -@Deprecated(since = "6.0", forRemoval = true) -public class CookieGenerator { - - /** - * Default path that cookies will be visible to: "/", i.e. the entire server. - */ - public static final String DEFAULT_COOKIE_PATH = "/"; - - - protected final Log logger = LogFactory.getLog(getClass()); - - private @Nullable String cookieName; - - private @Nullable String cookieDomain; - - private String cookiePath = DEFAULT_COOKIE_PATH; - - private @Nullable Integer cookieMaxAge; - - private boolean cookieSecure = false; - - private boolean cookieHttpOnly = false; - - - /** - * Use the given name for cookies created by this generator. - * @see jakarta.servlet.http.Cookie#getName() - */ - public void setCookieName(@Nullable String cookieName) { - this.cookieName = cookieName; - } - - /** - * Return the given name for cookies created by this generator. - */ - public @Nullable String getCookieName() { - return this.cookieName; - } - - /** - * Use the given domain for cookies created by this generator. - * The cookie is only visible to servers in this domain. - * @see jakarta.servlet.http.Cookie#setDomain - */ - public void setCookieDomain(@Nullable String cookieDomain) { - this.cookieDomain = cookieDomain; - } - - /** - * Return the domain for cookies created by this generator, if any. - */ - public @Nullable String getCookieDomain() { - return this.cookieDomain; - } - - /** - * Use the given path for cookies created by this generator. - * The cookie is only visible to URLs in this path and below. - * @see jakarta.servlet.http.Cookie#setPath - */ - public void setCookiePath(String cookiePath) { - this.cookiePath = cookiePath; - } - - /** - * Return the path for cookies created by this generator. - */ - public String getCookiePath() { - return this.cookiePath; - } - - /** - * Use the given maximum age (in seconds) for cookies created by this generator. - * Useful special value: -1 ... not persistent, deleted when client shuts down. - *

Default is no specific maximum age at all, using the Servlet container's - * default. - * @see jakarta.servlet.http.Cookie#setMaxAge - */ - public void setCookieMaxAge(@Nullable Integer cookieMaxAge) { - this.cookieMaxAge = cookieMaxAge; - } - - /** - * Return the maximum age for cookies created by this generator. - */ - public @Nullable Integer getCookieMaxAge() { - return this.cookieMaxAge; - } - - /** - * Set whether the cookie should only be sent using a secure protocol, - * such as HTTPS (SSL). This is an indication to the receiving browser, - * not processed by the HTTP server itself. - *

Default is "false". - * @see jakarta.servlet.http.Cookie#setSecure - */ - public void setCookieSecure(boolean cookieSecure) { - this.cookieSecure = cookieSecure; - } - - /** - * Return whether the cookie should only be sent using a secure protocol, - * such as HTTPS (SSL). - */ - public boolean isCookieSecure() { - return this.cookieSecure; - } - - /** - * Set whether the cookie is supposed to be marked with the "HttpOnly" attribute. - *

Default is "false". - * @see jakarta.servlet.http.Cookie#setHttpOnly - */ - public void setCookieHttpOnly(boolean cookieHttpOnly) { - this.cookieHttpOnly = cookieHttpOnly; - } - - /** - * Return whether the cookie is supposed to be marked with the "HttpOnly" attribute. - */ - public boolean isCookieHttpOnly() { - return this.cookieHttpOnly; - } - - - /** - * Add a cookie with the given value to the response, - * using the cookie descriptor settings of this generator. - *

Delegates to {@link #createCookie} for cookie creation. - * @param response the HTTP response to add the cookie to - * @param cookieValue the value of the cookie to add - * @see #setCookieName - * @see #setCookieDomain - * @see #setCookiePath - * @see #setCookieMaxAge - */ - public void addCookie(HttpServletResponse response, String cookieValue) { - Assert.notNull(response, "HttpServletResponse must not be null"); - Cookie cookie = createCookie(cookieValue); - Integer maxAge = getCookieMaxAge(); - if (maxAge != null) { - cookie.setMaxAge(maxAge); - } - if (isCookieSecure()) { - cookie.setSecure(true); - } - if (isCookieHttpOnly()) { - cookie.setHttpOnly(true); - } - response.addCookie(cookie); - if (logger.isTraceEnabled()) { - logger.trace("Added cookie [" + getCookieName() + "=" + cookieValue + "]"); - } - } - - /** - * Remove the cookie that this generator describes from the response. - * Will generate a cookie with empty value and max age 0. - *

Delegates to {@link #createCookie} for cookie creation. - * @param response the HTTP response to remove the cookie from - * @see #setCookieName - * @see #setCookieDomain - * @see #setCookiePath - */ - public void removeCookie(HttpServletResponse response) { - Assert.notNull(response, "HttpServletResponse must not be null"); - Cookie cookie = createCookie(""); - cookie.setMaxAge(0); - if (isCookieSecure()) { - cookie.setSecure(true); - } - if (isCookieHttpOnly()) { - cookie.setHttpOnly(true); - } - response.addCookie(cookie); - if (logger.isTraceEnabled()) { - logger.trace("Removed cookie '" + getCookieName() + "'"); - } - } - - /** - * Create a cookie with the given value, using the cookie descriptor - * settings of this generator (except for "cookieMaxAge"). - * @param cookieValue the value of the cookie to crate - * @return the cookie - * @see #setCookieName - * @see #setCookieDomain - * @see #setCookiePath - */ - protected Cookie createCookie(String cookieValue) { - Cookie cookie = new Cookie(getCookieName(), cookieValue); - if (getCookieDomain() != null) { - cookie.setDomain(getCookieDomain()); - } - cookie.setPath(getCookiePath()); - return cookie; - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/util/NestedServletException.java b/spring-web/src/main/java/org/springframework/web/util/NestedServletException.java deleted file mode 100644 index eb05b1545d05..000000000000 --- a/spring-web/src/main/java/org/springframework/web/util/NestedServletException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2002-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.web.util; - -import jakarta.servlet.ServletException; -import org.jspecify.annotations.Nullable; - -import org.springframework.core.NestedExceptionUtils; - -/** - * Legacy subclass of {@link ServletException} that handles a root cause in terms - * of message and stacktrace. - * - * @author Juergen Hoeller - * @since 1.2.5 - * @deprecated as of 6.0, in favor of standard {@link ServletException} nesting - */ -@Deprecated(since = "6.0") -public class NestedServletException extends ServletException { - - /** Use serialVersionUID from Spring 1.2 for interoperability. */ - private static final long serialVersionUID = -5292377985529381145L; - - static { - // Eagerly load the NestedExceptionUtils class to avoid classloader deadlock - // issues on OSGi when calling getMessage(). Reported by Don Brown; SPR-5607. - NestedExceptionUtils.class.getName(); - } - - - /** - * Construct a {@code NestedServletException} with the specified detail message. - * @param msg the detail message - */ - public NestedServletException(String msg) { - super(msg); - } - - /** - * Construct a {@code NestedServletException} with the specified detail message - * and nested exception. - * @param msg the detail message - * @param cause the nested exception - */ - public NestedServletException(@Nullable String msg, @Nullable Throwable cause) { - super(NestedExceptionUtils.buildMessage(msg, cause), cause); - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index c1d9930043ac..32273ee20ef1 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -216,27 +216,6 @@ public static UriComponentsBuilder fromUriString(String uri, ParserType parserTy }; } - /** - * Create a URI components builder from the given HTTP URL String. - *

Note: The presence of reserved characters can prevent - * correct parsing of the URI string. For example if a query parameter - * contains {@code '='} or {@code '&'} characters, the query string cannot - * be parsed unambiguously. Such values should be substituted for URI - * variables to enable correct parsing: - *

-	 * String urlString = "https://example.com/hotels/42?filter={value}";
-	 * UriComponentsBuilder.fromHttpUrl(urlString).buildAndExpand("hot&cold");
-	 * 
- * @param httpUrl the source URI - * @return the URI components of the URI - * @deprecated as of 6.2, in favor of {@link #fromUriString(String)}; - * scheduled for removal in 7.0. - */ - @Deprecated(since = "6.2") - public static UriComponentsBuilder fromHttpUrl(String httpUrl) throws InvalidUrlException { - return fromUriString(httpUrl); - } - // Encode methods diff --git a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java index 39fbc3e4b871..2a7328fcd232 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,7 +168,6 @@ void codeWithDeprecatedAlias(int code, HttpStatus expected, HttpStatus outdated) @SuppressWarnings("deprecation") static List codesWithAliases() { return List.of( - arguments(103, HttpStatus.EARLY_HINTS, HttpStatus.CHECKPOINT), arguments(302, HttpStatus.FOUND, HttpStatus.MOVED_TEMPORARILY), arguments(413, HttpStatus.PAYLOAD_TOO_LARGE, HttpStatus.REQUEST_ENTITY_TOO_LARGE), arguments(414, HttpStatus.URI_TOO_LONG, HttpStatus.REQUEST_URI_TOO_LONG) diff --git a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java index 56659ce69801..371163d67160 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -316,12 +316,11 @@ void statusCodeAsInt() { } @Test - @SuppressWarnings("deprecation") void customStatusCode() { Integer entity = 42; ResponseEntity responseEntity = ResponseEntity.status(299).body(entity); - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(299); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(299); assertThat(responseEntity.getBody()).isEqualTo(entity); } diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java index adce474d13c8..6be4b6673aaa 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java index 8ff840e81113..132ba9285057 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,17 +57,6 @@ void redirectScenarioWithRedirectModel() { assertThat(this.mavContainer.getModel().get("name2")).isEqualTo("value2"); } - @Test - @SuppressWarnings("deprecation") - public void redirectScenarioWithoutRedirectModel() { - this.mavContainer.setIgnoreDefaultModelOnRedirect(false); - this.mavContainer.addAttribute("name", "value"); - this.mavContainer.setRedirectModelScenario(true); - - assertThat(this.mavContainer.getModel()).hasSize(1); - assertThat(this.mavContainer.getModel().get("name")).isEqualTo("value"); - } - @Test void ignoreDefaultModel() { this.mavContainer.addAttribute("name", "value"); diff --git a/spring-web/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java b/spring-web/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java deleted file mode 100644 index eb3a2c16f785..000000000000 --- a/spring-web/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2024 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.web.util; - -import org.junit.jupiter.api.Test; - -import org.springframework.core.NestedExceptionUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -@SuppressWarnings("deprecation") -public class NestedServletExceptionTests { - - @Test - void testNestedServletExceptionString() { - NestedServletException exception = new NestedServletException("foo"); - assertThat(exception.getMessage()).isEqualTo("foo"); - } - - @Test - void testNestedServletExceptionStringThrowable() { - Throwable cause = new RuntimeException(); - NestedServletException exception = new NestedServletException("foo", cause); - assertThat(exception.getMessage()).isEqualTo(NestedExceptionUtils.buildMessage("foo", cause)); - assertThat(exception.getCause()).isEqualTo(cause); - } - - @Test - void testNestedServletExceptionStringNullThrowable() { - // This can happen if someone is sloppy with Throwable causes... - NestedServletException exception = new NestedServletException("foo", null); - assertThat(exception.getMessage()).isEqualTo("foo"); - } - -} diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java index b72328fc26a5..fc2d4f5fa8c3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java @@ -190,7 +190,6 @@ void bodyToFluxTypeReference() { } @Test - @SuppressWarnings("deprecation") void toEntity() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -202,12 +201,10 @@ void toEntity() { ResponseEntity result = defaultClientResponse.toEntity(String.class).block(); assertThat(result.getBody()).isEqualTo("foo"); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(result.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } @Test - @SuppressWarnings("deprecation") void toEntityWithUnknownStatusCode() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -222,13 +219,11 @@ void toEntityWithUnknownStatusCode() { ResponseEntity result = defaultClientResponse.toEntity(String.class).block(); assertThat(result.getBody()).isEqualTo("foo"); - assertThat(result.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(999)); - assertThat(result.getStatusCodeValue()).isEqualTo(999); + assertThat(result.getStatusCode().value()).isEqualTo(999); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } @Test - @SuppressWarnings("deprecation") void toEntityTypeReference() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -240,12 +235,10 @@ void toEntityTypeReference() { ResponseEntity result = defaultClientResponse.toEntity(STRING_TYPE).block(); assertThat(result.getBody()).isEqualTo("foo"); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(result.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } @Test - @SuppressWarnings("deprecation") void toEntityList() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -257,12 +250,10 @@ void toEntityList() { ResponseEntity> result = defaultClientResponse.toEntityList(String.class).block(); assertThat(result.getBody()).containsExactly("foo"); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(result.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } @Test - @SuppressWarnings("deprecation") void toEntityListWithUnknownStatusCode() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -278,12 +269,10 @@ void toEntityListWithUnknownStatusCode() { ResponseEntity> result = defaultClientResponse.toEntityList(String.class).block(); assertThat(result.getBody()).containsExactly("foo"); assertThat(result.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(999)); - assertThat(result.getStatusCodeValue()).isEqualTo(999); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } @Test - @SuppressWarnings("deprecation") void toEntityListTypeReference() { byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8); DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes); @@ -296,7 +285,6 @@ void toEntityListTypeReference() { ResponseEntity> result = defaultClientResponse.toEntityList(STRING_TYPE).block(); assertThat(result.getBody()).containsExactly("foo"); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(result.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); assertThat(result.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index f30a99f8a1d3..7b4f2567e4c0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1150,7 +1150,6 @@ void exchangeFor404(ClientHttpConnector connector) { } @ParameterizedWebClientTest - @SuppressWarnings("deprecation") void exchangeForUnknownStatusCode(ClientHttpConnector connector) { startServer(connector); @@ -1165,7 +1164,7 @@ void exchangeForUnknownStatusCode(ClientHttpConnector connector) { .exchangeToMono(ClientResponse::toBodilessEntity); StepVerifier.create(result) - .consumeNextWith(entity -> assertThat(entity.getStatusCodeValue()).isEqualTo(555)) + .consumeNextWith(entity -> assertThat(entity.getStatusCode().value()).isEqualTo(555)) .expectComplete() .verify(Duration.ofSeconds(3)); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 50134833d097..0787d197b289 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,8 +182,6 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter private ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); - private boolean ignoreDefaultModelOnRedirect = true; - private int cacheSecondsForSessionAttributeHandlers = 0; private boolean synchronizeOnSession = false; @@ -468,26 +466,6 @@ public ReactiveAdapterRegistry getReactiveAdapterRegistry() { return this.reactiveAdapterRegistry; } - /** - * By default, the content of the "default" model is used both during - * rendering and redirect scenarios. Alternatively a controller method - * can declare a {@link RedirectAttributes} argument and use it to provide - * attributes for a redirect. - *

Setting this flag to {@code true} guarantees the "default" model is - * never used in a redirect scenario even if a RedirectAttributes argument - * is not declared. Setting it to {@code false} means the "default" model - * may be used in a redirect if the controller method doesn't declare a - * RedirectAttributes argument. - *

As of 6.0, this property is set to {@code true} by default. - * @see RedirectAttributes - * @deprecated as of 6.0 without a replacement; once removed, the default - * model will always be ignored on redirect - */ - @Deprecated(since = "6.0") - public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect) { - this.ignoreDefaultModelOnRedirect = ignoreDefaultModelOnRedirect; - } - /** * Specify the strategy to store session attributes with. The default is * {@link org.springframework.web.bind.support.DefaultSessionAttributeStore}, @@ -947,7 +925,6 @@ private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handl ModelAndViewContainer mavContainer = new ModelAndViewContainer(); mavContainer.addAllAttributes(RequestContextUtils.getInputFlashMap(request)); modelFactory.initModel(webRequest, mavContainer, invocableMethod); - mavContainer.setIgnoreDefaultModelOnRedirect(this.ignoreDefaultModelOnRedirect); if (asyncManager.hasConcurrentResult()) { Object result = asyncManager.getConcurrentResult();