Remove deprecated APIs in spring-web

See gh-33809
This commit is contained in:
rstoyanchev
2025-01-13 16:30:14 +00:00
parent 00ee0ab99c
commit 9ddbf800b9
16 changed files with 19 additions and 545 deletions

View File

@@ -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 href="https://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal">A proposal for supporting
* resumable POST/PUT HTTP requests in HTTP/1.0</a>
* @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

View File

@@ -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 class ResponseEntity<T> extends HttpEntity<T> {
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) {

View File

@@ -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}.
*
* <p>This factory implements {@link InitializingBean}, {@link DisposableBean}
* and {@link Lifecycle} and is expected typically to be declared as a
* Spring-managed bean.
*
* <p>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 {
}

View File

@@ -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 class UnknownContentTypeException extends RestClientException {
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.
*/

View File

@@ -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 @@ import org.springframework.web.bind.support.SimpleSessionStatus;
*/
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.
* <p>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.
* <p>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 class ModelAndViewContainer {
* 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 class ModelAndViewContainer {
else {
sb.append("View is [").append(this.view).append(']');
}
if (useDefaultModel()) {
if (!this.redirectModelScenario) {
sb.append("; default model ");
}
else {

View File

@@ -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.
*
* <p>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.
* <p>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.
* <p>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.
* <p>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.
* <p>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.
* <p>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;
}
}

View File

@@ -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);
}
}

View File

@@ -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 class UriComponentsBuilder implements UriBuilder, Cloneable {
};
}
/**
* Create a URI components builder from the given HTTP URL String.
* <p><strong>Note:</strong> 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:
* <pre class="code">
* String urlString = &quot;https://example.com/hotels/42?filter={value}&quot;;
* UriComponentsBuilder.fromHttpUrl(urlString).buildAndExpand(&quot;hot&amp;cold&quot;);
* </pre>
* @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

View File

@@ -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 @@ class HttpStatusTests {
@SuppressWarnings("deprecation")
static List<Arguments> 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)

View File

@@ -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 @@ class ResponseEntityTests {
}
@Test
@SuppressWarnings("deprecation")
void customStatusCode() {
Integer entity = 42;
ResponseEntity<Integer> responseEntity = ResponseEntity.status(299).body(entity);
assertThat(responseEntity.getStatusCodeValue()).isEqualTo(299);
assertThat(responseEntity.getStatusCode().value()).isEqualTo(299);
assertThat(responseEntity.getBody()).isEqualTo(entity);
}

View File

@@ -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.

View File

@@ -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 @@ class ModelAndViewContainerTests {
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");

View File

@@ -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");
}
}

View File

@@ -190,7 +190,6 @@ class DefaultClientResponseTests {
}
@Test
@SuppressWarnings("deprecation")
void toEntity() {
byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8);
DataBuffer dataBuffer = DefaultDataBufferFactory.sharedInstance.wrap(bytes);
@@ -202,12 +201,10 @@ class DefaultClientResponseTests {
ResponseEntity<String> 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 @@ class DefaultClientResponseTests {
ResponseEntity<String> 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 @@ class DefaultClientResponseTests {
ResponseEntity<String> 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 @@ class DefaultClientResponseTests {
ResponseEntity<List<String>> 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 @@ class DefaultClientResponseTests {
ResponseEntity<List<String>> 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 @@ class DefaultClientResponseTests {
ResponseEntity<List<String>> 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);
}

View File

@@ -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 @@ class WebClientIntegrationTests {
}
@ParameterizedWebClientTest
@SuppressWarnings("deprecation")
void exchangeForUnknownStatusCode(ClientHttpConnector connector) {
startServer(connector);
@@ -1165,7 +1164,7 @@ class WebClientIntegrationTests {
.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));

View File

@@ -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 class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
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.
* <p>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.
* <p>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 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
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();