diff --git a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java index 32bd66ad932..9fac4754ab4 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.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. @@ -127,12 +127,6 @@ public final class MockServerRequest implements ServerRequest { return this.method; } - @Override - @Deprecated - public String methodName() { - return this.method.name(); - } - @Override public URI uri() { return this.uri; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index 205f6bd3b6f..c488e497982 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.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. @@ -129,27 +129,6 @@ public abstract class BodyInserters { writeWithMessageWriters(message, context, Mono.just(body), ResolvableType.forType(bodyType), null); } - /** - * Inserter to write the given object. - *

Alternatively, consider using the {@code bodyValue(Object)} shortcuts on - * {@link org.springframework.web.reactive.function.client.WebClient WebClient} and - * {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}. - * @param body the body to write to the response - * @param the type of the body - * @return the inserter to write a single object - * @throws IllegalArgumentException if {@code body} is a {@link Publisher} or an - * instance of a type supported by {@link ReactiveAdapterRegistry#getSharedInstance()}, - * for which {@link #fromPublisher(Publisher, Class)} or - * {@link #fromProducer(Object, Class)} should be used. - * @see #fromPublisher(Publisher, Class) - * @see #fromProducer(Object, Class) - * @deprecated As of Spring Framework 5.2, in favor of {@link #fromValue(Object)} - */ - @Deprecated - public static BodyInserter fromObject(T body) { - return fromValue(body); - } - /** * Inserter to write the given producer of value(s) which must be a {@link Publisher} * or another producer adaptable to a {@code Publisher} via diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java index 3a698356b53..81837665650 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 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. @@ -133,18 +133,6 @@ public interface ClientRequest { return new DefaultClientRequestBuilder(other); } - /** - * Create a builder with the given HTTP method and url. - * @param method the HTTP method (GET, POST, etc) - * @param url the url (as a URI instance) - * @return the created builder - * @deprecated in favor of {@link #create(HttpMethod, URI)} - */ - @Deprecated - static Builder method(HttpMethod method, URI url) { - return new DefaultClientRequestBuilder(method, url); - } - /** * Create a request builder with the given HTTP method and url. * @param method the HTTP method (GET, POST, etc) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 9f076f3e4fb..d781ef28c2c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.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. @@ -211,21 +211,6 @@ public interface ClientResponse { // Static builder methods - /** - * Create a builder with the status, headers, and cookies of the given response. - *

Note: Note that the body in the returned builder is - * {@link Flux#empty()} by default. To carry over the one from the original - * response, use {@code otherResponse.bodyToFlux(DataBuffer.class)} or - * simply use the instance based {@link #mutate()} method. - * @param other the response to copy the status, headers, and cookies from - * @return the created builder - * @deprecated as of 5.3 in favor of the instance based {@link #mutate()}. - */ - @Deprecated - static Builder from(ClientResponse other) { - return new DefaultClientResponseBuilder(other, false); - } - /** * Create a response builder with the given status code and using default strategies for * reading the body. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java index 9b32b5bae69..b254e8ef306 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java @@ -39,7 +39,6 @@ import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.SignalType; -import reactor.util.context.Context; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; @@ -207,8 +206,6 @@ final class DefaultWebClient implements WebClient { private final Map attributes = new LinkedHashMap<>(4); - private @Nullable Function contextModifier; - private @Nullable Consumer httpRequestConsumer; DefaultRequestBodyUriSpec(HttpMethod httpMethod) { @@ -335,14 +332,6 @@ final class DefaultWebClient implements WebClient { return this; } - @SuppressWarnings("deprecation") - @Override - public RequestBodySpec context(Function contextModifier) { - this.contextModifier = (this.contextModifier != null ? - this.contextModifier.andThen(contextModifier) : contextModifier); - return this; - } - @Override public RequestBodySpec httpRequest(Consumer requestConsumer) { this.httpRequestConsumer = (this.httpRequestConsumer != null ? @@ -393,12 +382,6 @@ final class DefaultWebClient implements WebClient { return this; } - @Override - @Deprecated - public RequestHeadersSpec syncBody(Object body) { - return bodyValue(body); - } - @Override public ResponseSpec retrieve() { return new DefaultResponseSpec( @@ -434,9 +417,7 @@ final class DefaultWebClient implements WebClient { }); } - @SuppressWarnings("deprecation") - @Override - public Mono exchange() { + private Mono exchange() { ClientRequest.Builder requestBuilder = initRequestBuilder(); ClientRequestObservationContext observationContext = new ClientRequestObservationContext(requestBuilder); return Mono.deferContextual(contextView -> { @@ -459,9 +440,6 @@ final class DefaultWebClient implements WebClient { WebClientUtils.getRequestDescription(request.method(), request.url()) + " [DefaultWebClient]") .switchIfEmpty(NO_HTTP_CLIENT_RESPONSE_ERROR); - if (this.contextModifier != null) { - responseMono = responseMono.contextWrite(this.contextModifier); - } final AtomicBoolean responseReceived = new AtomicBoolean(); return responseMono .doOnNext(response -> responseReceived.set(true)) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index 867bc97e547..6318e3d739f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.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. @@ -251,16 +251,6 @@ final class DefaultWebClientBuilder implements WebClient.Builder { return this; } - @Override - @Deprecated - public WebClient.Builder exchangeStrategies(Consumer configurer) { - if (this.strategiesConfigurers == null) { - this.strategiesConfigurers = new ArrayList<>(4); - } - this.strategiesConfigurers.add(configurer); - return this; - } - @Override public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) { this.exchangeFunction = exchangeFunction; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java index 991485f5e10..f51f15babbb 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.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. @@ -17,12 +17,9 @@ package org.springframework.web.reactive.function.client; import java.nio.charset.Charset; -import java.util.Map; -import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import org.jspecify.annotations.Nullable; import reactor.core.publisher.Mono; import org.springframework.core.io.buffer.DataBufferUtils; @@ -41,13 +38,6 @@ import org.springframework.util.Assert; */ public abstract class ExchangeFilterFunctions { - /** - * Name of the request attribute with {@link Credentials} for {@link #basicAuthentication()}. - */ - private static final String BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE = - ExchangeFilterFunctions.class.getName() + ".basicAuthenticationCredentials"; - - /** * Consume up to the specified number of bytes from the response body and * cancel if any more data arrives. @@ -100,81 +90,4 @@ public abstract class ExchangeFilterFunctions { .build()); } - /** - * Variant of {@link #basicAuthentication(String, String)} that looks up - * the {@link Credentials Credentials} in a - * {@link #BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE request attribute}. - * @return the filter to use - * @see Credentials - * @deprecated as of Spring 5.1 in favor of using - * {@link HttpHeaders#setBasicAuth(String, String)} while building the request. - */ - @Deprecated - public static ExchangeFilterFunction basicAuthentication() { - return (request, next) -> { - Object attr = request.attributes().get(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE); - if (attr instanceof Credentials cred) { - return next.exchange(ClientRequest.from(request) - .headers(headers -> headers.setBasicAuth(cred.username, cred.password)) - .build()); - } - else { - return next.exchange(request); - } - }; - } - - - /** - * Stores username and password for HTTP basic authentication. - * @deprecated as of Spring 5.1 in favor of using - * {@link HttpHeaders#setBasicAuth(String, String)} while building the request. - */ - @Deprecated - public static final class Credentials { - - private final String username; - - private final String password; - - /** - * Create a new {@code Credentials} instance with the given username and password. - * @param username the username - * @param password the password - */ - public Credentials(String username, String password) { - Assert.notNull(username, "'username' must not be null"); - Assert.notNull(password, "'password' must not be null"); - this.username = username; - this.password = password; - } - - /** - * Return a {@literal Consumer} that stores the given username and password - * as a request attribute of type {@code Credentials} that is in turn - * used by {@link ExchangeFilterFunctions#basicAuthentication()}. - * @param username the username - * @param password the password - * @return a consumer that can be passed into - * {@linkplain ClientRequest.Builder#attributes(java.util.function.Consumer)} - * @see ClientRequest.Builder#attributes(java.util.function.Consumer) - * @see #BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE - */ - public static Consumer> basicAuthenticationCredentials(String username, String password) { - Credentials credentials = new Credentials(username, password); - return (map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials)); - } - - @Override - public boolean equals(@Nullable Object other) { - return (this == other ||(other instanceof Credentials that && - this.username.equals(that.username) && this.password.equals(that.password))); - } - - @Override - public int hashCode() { - return this.username.hashCode() * 31 + this.password.hashCode(); - } - } - } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index a7f6c528dfb..3921a9e131f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.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. @@ -32,7 +32,6 @@ import org.jspecify.annotations.Nullable; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.util.context.Context; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ReactiveAdapterRegistry; @@ -320,16 +319,6 @@ public interface WebClient { */ Builder exchangeStrategies(ExchangeStrategies strategies); - /** - * Customize the strategies configured via - * {@link #exchangeStrategies(ExchangeStrategies)}. This method is - * designed for use in scenarios where multiple parties wish to update - * the {@code ExchangeStrategies}. - * @deprecated as of 5.1.13 in favor of {@link #codecs(Consumer)} - */ - @Deprecated - Builder exchangeStrategies(Consumer configurer); - /** * Provide an {@link ExchangeFunction} pre-configured with * {@link ClientHttpConnector} and {@link ExchangeStrategies}. @@ -502,17 +491,6 @@ public interface WebClient { */ S attributes(Consumer> attributesConsumer); - /** - * Provide a function to populate the Reactor {@code Context}. - * @param contextModifier the function to modify the context with - * @since 5.3.1 - * @deprecated in 5.3.2 to be removed soon after; this method cannot - * provide context to downstream (nested or subsequent) requests and is - * of limited value. - */ - @Deprecated - S context(Function contextModifier); - /** * Callback for access to the {@link ClientHttpRequest} that in turn * provides access to the native request of the underlying HTTP library. @@ -606,44 +584,6 @@ public interface WebClient { * @since 5.3 */ Flux exchangeToFlux(Function> responseHandler); - - /** - * Perform the HTTP request and return a {@link ClientResponse} with the - * response status and headers. You can then use methods of the response - * to consume the body: - *

-		 * Mono<Person> mono = client.get()
-		 *     .uri("/persons/1")
-		 *     .accept(MediaType.APPLICATION_JSON)
-		 *     .exchange()
-		 *     .flatMap(response -> response.bodyToMono(Person.class));
-		 *
-		 * Flux<Person> flux = client.get()
-		 *     .uri("/persons")
-		 *     .accept(MediaType.APPLICATION_STREAM_JSON)
-		 *     .exchange()
-		 *     .flatMapMany(response -> response.bodyToFlux(Person.class));
-		 * 
- *

NOTE: Unlike {@link #retrieve()}, when using - * {@code exchange()}, it is the responsibility of the application to - * consume any response content regardless of the scenario (success, - * error, unexpected data, etc). Not doing so can cause a memory leak. - * See {@link ClientResponse} for a list of all the available options - * for consuming the body. Generally prefer using {@link #retrieve()} - * unless you have a good reason to use {@code exchange()} which does - * allow to check the response status and headers before deciding how or - * if to consume the response. - * @return a {@code Mono} for the response - * @see #retrieve() - * @deprecated since 5.3 due to the possibility to leak memory and/or - * connections; please, use {@link #exchangeToMono(Function)}, - * {@link #exchangeToFlux(Function)}; consider also using - * {@link #retrieve()} which provides access to the response status - * and headers via {@link ResponseEntity} along with error status - * handling. - */ - @Deprecated - Mono exchange(); } @@ -789,15 +729,6 @@ public interface WebClient { * @see org.springframework.web.reactive.function.BodyInserters */ RequestHeadersSpec body(BodyInserter inserter); - - /** - * Shortcut for {@link #body(BodyInserter)} with a - * {@linkplain BodyInserters#fromValue value inserter}. - * As of 5.2 this method delegates to {@link #bodyValue(Object)}. - * @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)} - */ - @Deprecated - RequestHeadersSpec syncBody(Object body); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java index 258159c55b3..557ab3145c5 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientResponseException.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. @@ -168,15 +168,6 @@ public class WebClientResponseException extends WebClientException { 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-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java index caf09e15bcb..23e9aa82de9 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.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. @@ -122,12 +122,6 @@ class DefaultServerRequest implements ServerRequest { return request().getMethod(); } - @Override - @Deprecated - public String methodName() { - return request().getMethod().name(); - } - @Override public URI uri() { return request().getURI(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java index f43ecf35441..090f0450b02 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.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. @@ -260,12 +260,6 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder { this.statusCode, this.headers, this.cookies, inserter, this.hints)); } - @Override - @Deprecated - public Mono syncBody(Object body) { - return bodyValue(body); - } - @Override public Mono render(String name, Object... modelAttributes) { return new DefaultRenderingResponseBuilder(name) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java index 3027acf9e55..6ee7be2c2c2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.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. @@ -1144,12 +1144,6 @@ public abstract class RequestPredicates { return this.delegate.method(); } - @Override - @Deprecated - public String methodName() { - return this.delegate.methodName(); - } - @Override public URI uri() { return this.delegate.uri(); @@ -1165,12 +1159,6 @@ public abstract class RequestPredicates { return this.delegate.path(); } - @Override - @Deprecated - public PathContainer pathContainer() { - return this.delegate.pathContainer(); - } - @Override public RequestPath requestPath() { return this.delegate.requestPath(); @@ -1415,11 +1403,5 @@ public abstract class RequestPredicates { public String path() { return this.requestPath.pathWithinApplication().value(); } - - @Override - @Deprecated - public PathContainer pathContainer() { - return this.requestPath; - } } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java index 110f906598b..4f3263c4c37 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.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. @@ -42,7 +42,6 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.json.Jackson2CodecSupport; import org.springframework.http.codec.multipart.Part; -import org.springframework.http.server.PathContainer; import org.springframework.http.server.RequestPath; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.util.Assert; @@ -72,14 +71,6 @@ public interface ServerRequest { */ HttpMethod method(); - /** - * Get the name of the HTTP method. - * @return the HTTP method as a String - * @deprecated as of 6.0, in favor of {@link #method()} - */ - @Deprecated(since = "6.0") - String methodName(); - /** * Get the request URI. */ @@ -103,15 +94,6 @@ public interface ServerRequest { return requestPath().pathWithinApplication().value(); } - /** - * Get the request path as a {@code PathContainer}. - * @deprecated as of 5.3, in favor on {@link #requestPath()} - */ - @Deprecated - default PathContainer pathContainer() { - return requestPath(); - } - /** * Get the request path as a {@code PathContainer}. * @since 5.3 diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java index 3ab988cbc5f..1e52b9a3f49 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.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. @@ -480,14 +480,6 @@ public interface ServerResponse { */ Mono body(BodyInserter inserter); - /** - * Set the response body to the given {@code Object} and return it. - * As of 5.2 this method delegates to {@link #bodyValue(Object)}. - * @deprecated as of Spring Framework 5.2 in favor of {@link #bodyValue(Object)} - */ - @Deprecated - Mono syncBody(Object body); - /** * Render the template with the given {@code name} using the given {@code modelAttributes}. * The model attributes are mapped under a diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java index 1d9fc1f3654..8f0ebceaafa 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.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. @@ -39,7 +39,6 @@ import org.springframework.http.HttpRange; import org.springframework.http.MediaType; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.multipart.Part; -import org.springframework.http.server.PathContainer; import org.springframework.http.server.RequestPath; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.util.Assert; @@ -87,12 +86,6 @@ public class ServerRequestWrapper implements ServerRequest { return this.delegate.method(); } - @Override - @Deprecated - public String methodName() { - return this.delegate.methodName(); - } - @Override public URI uri() { return this.delegate.uri(); @@ -108,12 +101,6 @@ public class ServerRequestWrapper implements ServerRequest { return this.delegate.path(); } - @Override - @Deprecated - public PathContainer pathContainer() { - return this.delegate.pathContainer(); - } - @Override public RequestPath requestPath() { return this.delegate.requestPath(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java index 3d28c33b277..1938b430518 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.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. @@ -92,42 +92,6 @@ public final class RequestMappingInfo implements RequestCondition custom) { - - this(name, patterns, methods, params, headers, consumes, produces, custom, new BuilderConfiguration()); - } - - /** - * Create an instance with the given conditions. - * @deprecated as of 5.3.4 in favor using {@link RequestMappingInfo.Builder} via {@link #paths(String...)}. - */ - @Deprecated - public RequestMappingInfo(@Nullable PatternsRequestCondition patterns, - @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, - @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, - @Nullable ProducesRequestCondition produces, @Nullable RequestCondition custom) { - - this(null, patterns, methods, params, headers, consumes, produces, custom); - } - - /** - * Re-create a RequestMappingInfo with the given custom request condition. - * @deprecated since 5.3.4 in favor of using a {@link Builder} via {@link #mutate()}. - */ - @Deprecated - public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition customRequestCondition) { - this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition, - info.consumesCondition, info.producesCondition, customRequestCondition); - } - private RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns, @Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params, @Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes, diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java index fd2d4c32659..57439ba5640 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -59,7 +59,7 @@ public class RequestHeaderMapMethodArgumentResolver extends HandlerMethodArgumen } - @SuppressWarnings("deprecation") + @SuppressWarnings("removal") @Override public Object resolveArgumentValue( MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java index 6069a76b00d..81d3489bb92 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.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. @@ -186,14 +186,6 @@ public final class CloseStatus { return new CloseStatus(this.code, reason); } - /** - * @deprecated as of 5.3 in favor of comparing codes directly - */ - @Deprecated - public boolean equalsCode(CloseStatus other) { - return (this.code == other.code); - } - /** * Return a constant for the given code, or create a new instance if the diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/HandshakeInfo.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/HandshakeInfo.java index f2f9d0c540e..440670d84da 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/HandshakeInfo.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/HandshakeInfo.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. @@ -73,28 +73,6 @@ public class HandshakeInfo { this(uri, headers, EMPTY_COOKIES, principal, protocol, null, Collections.emptyMap(), null); } - /** - * Constructor targeting server-side use with extra information such as - * the remote address, attributes, and a log prefix. - * @param uri the endpoint URL - * @param headers server request headers - * @param principal the principal for the session - * @param protocol the negotiated sub-protocol (may be {@code null}) - * @param remoteAddress the remote address of the client - * @param attributes initial attributes for the WebSocket session - * @param logPrefix the log prefix for the handshake request. - * @since 5.1 - * @deprecated as of 5.3.5 in favor of - * {@link #HandshakeInfo(URI, HttpHeaders, MultiValueMap, Mono, String, InetSocketAddress, Map, String)} - */ - @Deprecated - public HandshakeInfo(URI uri, HttpHeaders headers, Mono principal, - @Nullable String protocol, @Nullable InetSocketAddress remoteAddress, - Map attributes, @Nullable String logPrefix) { - - this(uri, headers, EMPTY_COOKIES, principal, protocol, remoteAddress, attributes, logPrefix); - } - /** * Constructor targeting server-side use with extra information such as the * cookies, remote address, attributes, and a log prefix. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java index 2fbabf926a0..8646ba40bae 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. @@ -119,64 +119,6 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { return builder.build(); } - /** - * Configure the maximum allowable frame payload length. Setting this value - * to your application's requirement may reduce denial of service attacks - * using long data frames. - *

Corresponds to the argument with the same name in the constructor of - * {@link io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory - * WebSocketServerHandshakerFactory} in Netty. - *

By default set to 65536 (64K). - * @param maxFramePayloadLength the max length for frames. - * @since 5.2 - * @deprecated as of 5.3 in favor of providing a supplier of - * {@link reactor.netty.http.client.WebsocketClientSpec.Builder} with a - * constructor argument - */ - @Deprecated - public void setMaxFramePayloadLength(int maxFramePayloadLength) { - this.maxFramePayloadLength = maxFramePayloadLength; - } - - /** - * Return the configured {@link #setMaxFramePayloadLength(int) maxFramePayloadLength}. - * @since 5.2 - * @deprecated as of 5.3 in favor of {@link #getWebsocketClientSpec()} - */ - @Deprecated - public int getMaxFramePayloadLength() { - return getWebsocketClientSpec().maxFramePayloadLength(); - } - - /** - * Configure whether to let ping frames through to be handled by the - * {@link WebSocketHandler} given to the execute method. By default, Reactor - * Netty automatically replies with pong frames in response to pings. This is - * useful in a proxy for allowing ping and pong frames through. - *

By default this is set to {@code false} in which case ping frames are - * handled automatically by Reactor Netty. If set to {@code true}, ping - * frames will be passed through to the {@link WebSocketHandler}. - * @param handlePing whether to let Ping frames through for handling - * @since 5.2.4 - * @deprecated as of 5.3 in favor of providing a supplier of - * {@link reactor.netty.http.client.WebsocketClientSpec.Builder} with a - * constructor argument - */ - @Deprecated - public void setHandlePing(boolean handlePing) { - this.handlePing = handlePing; - } - - /** - * Return the configured {@link #setHandlePing(boolean)}. - * @since 5.2.4 - * @deprecated as of 5.3 in favor of {@link #getWebsocketClientSpec()} - */ - @Deprecated - public boolean getHandlePing() { - return getWebsocketClientSpec().handlePing(); - } - @Override public Mono execute(URI url, WebSocketHandler handler) { return execute(url, new HttpHeaders(), handler); @@ -194,8 +136,7 @@ public class ReactorNettyWebSocketClient implements WebSocketClient { String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol"); HandshakeInfo info = new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol); NettyDataBufferFactory factory = new NettyDataBufferFactory(outbound.alloc()); - WebSocketSession session = new ReactorNettyWebSocketSession( - inbound, outbound, info, factory, getMaxFramePayloadLength()); + WebSocketSession session = new ReactorNettyWebSocketSession(inbound, outbound, info, factory); if (logger.isDebugEnabled()) { logger.debug("Started session '" + session.getId() + "' for " + url); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java index 7a2f84bdc79..375386b38f5 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/upgrade/ReactorNettyRequestUpgradeStrategy.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. @@ -94,64 +94,6 @@ public class ReactorNettyRequestUpgradeStrategy implements RequestUpgradeStrateg return builder.build(); } - /** - * Configure the maximum allowable frame payload length. Setting this value - * to your application's requirement may reduce denial of service attacks - * using long data frames. - *

Corresponds to the argument with the same name in the constructor of - * {@link io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory - * WebSocketServerHandshakerFactory} in Netty. - *

By default set to 65536 (64K). - * @param maxFramePayloadLength the max length for frames. - * @since 5.1 - * @deprecated as of 5.2.6 in favor of providing a supplier of - * {@link reactor.netty.http.server.WebsocketServerSpec.Builder} with a - * constructor argument - */ - @Deprecated - public void setMaxFramePayloadLength(Integer maxFramePayloadLength) { - this.maxFramePayloadLength = maxFramePayloadLength; - } - - /** - * Return the configured max length for frames. - * @since 5.1 - * @deprecated as of 5.2.6 in favor of {@link #getWebsocketServerSpec()} - */ - @Deprecated - public int getMaxFramePayloadLength() { - return getWebsocketServerSpec().maxFramePayloadLength(); - } - - /** - * Configure whether to let ping frames through to be handled by the - * {@link WebSocketHandler} given to the upgrade method. By default, Reactor - * Netty automatically replies with pong frames in response to pings. This is - * useful in a proxy for allowing ping and pong frames through. - *

By default this is set to {@code false} in which case ping frames are - * handled automatically by Reactor Netty. If set to {@code true}, ping - * frames will be passed through to the {@link WebSocketHandler}. - * @param handlePing whether to let Ping frames through for handling - * @since 5.2.4 - * @deprecated as of 5.2.6 in favor of providing a supplier of - * {@link reactor.netty.http.server.WebsocketServerSpec.Builder} with a - * constructor argument - */ - @Deprecated - public void setHandlePing(boolean handlePing) { - this.handlePing = handlePing; - } - - /** - * Return the configured {@link #setHandlePing(boolean)}. - * @since 5.2.4 - * @deprecated as of 5.2.6 in favor of {@link #getWebsocketServerSpec()} - */ - @Deprecated - public boolean getHandlePing() { - return getWebsocketServerSpec().handlePing(); - } - @Override public Mono upgrade(ServerWebExchange exchange, WebSocketHandler handler, diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt index d8d5a19479b..2f1e61c9b58 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt @@ -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. @@ -18,12 +18,11 @@ package org.springframework.web.reactive.function.client import kotlinx.coroutines.Job import kotlinx.coroutines.currentCoroutineContext -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.asFlow +import kotlinx.coroutines.reactor.asFlux import kotlinx.coroutines.reactor.awaitSingle import kotlinx.coroutines.reactor.awaitSingleOrNull -import kotlinx.coroutines.reactor.asFlux import kotlinx.coroutines.reactor.mono import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference @@ -82,19 +81,6 @@ inline fun RequestBodySpec.body(producer: Any): RequestHeaders inline fun RequestBodySpec.bodyValueWithType(body: T): RequestHeadersSpec<*> = bodyValue(body, object : ParameterizedTypeReference() {}) -/** - * Coroutines variant of [WebClient.RequestHeadersSpec.exchange]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Suppress("DEPRECATION") -@Deprecated("Deprecated since 5.3 due to the possibility to leak memory and/or connections; please," + - "use awaitExchange { } or exchangeToFlow { } instead; consider also using retrieve()" + - "which provides access to the response status and headers via ResponseEntity along with error status handling.") -suspend fun RequestHeadersSpec>.awaitExchange(): ClientResponse = - exchange().awaitSingle() - /** * Coroutines variant of [WebClient.RequestHeadersSpec.exchangeToMono]. * diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt index b3d6a9a15c4..4f9e3f0d9ab 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt @@ -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. @@ -85,18 +85,6 @@ suspend inline fun ServerResponse.BodyBuilder.bodyValueWithType suspend inline fun ServerResponse.BodyBuilder.bodyAndAwait(flow: Flow): ServerResponse = body(flow, object : ParameterizedTypeReference() {}).awaitSingle() -/** - * Extension for [ServerResponse.BodyBuilder.body] providing a - * `bodyToServerSentEvents(Publisher)` variant. This extension is not subject to type - * erasure and retains actual generic type arguments. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -@Deprecated("Use 'sse().body(publisher)' instead.", replaceWith = ReplaceWith("sse().body(publisher)")) -inline fun ServerResponse.BodyBuilder.bodyToServerSentEvents(publisher: Publisher): Mono = - contentType(MediaType.TEXT_EVENT_STREAM).body(publisher, object : ParameterizedTypeReference() {}) - /** * Shortcut for setting [MediaType.APPLICATION_JSON] `Content-Type` header. * @author Sebastien Deleuze diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/server/ServerWebExchangeExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/server/ServerWebExchangeExtensions.kt deleted file mode 100644 index ad513b3bf25..00000000000 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/server/ServerWebExchangeExtensions.kt +++ /dev/null @@ -1,91 +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.reactive.server - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.reactor.awaitSingle -import kotlinx.coroutines.reactor.mono -import org.springframework.http.codec.multipart.Part -import org.springframework.util.MultiValueMap -import org.springframework.web.server.ServerWebExchange -import org.springframework.web.server.WebSession -import java.security.Principal - -/** - * Coroutines variant of [ServerWebExchange.getFormData]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Deprecated( - message = "Use the variant with the org.springframework.web.server package instead.", - ReplaceWith("awaitFormData()", "org.springframework.web.server.awaitFormData"), -) -suspend fun ServerWebExchange.awaitFormData(): MultiValueMap = - this.formData.awaitSingle() - -/** - * Coroutines variant of [ServerWebExchange.getMultipartData]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Deprecated( - message = "Use the variant with the org.springframework.web.server package instead.", - ReplaceWith("awaitMultipartData()", "org.springframework.web.server.awaitMultipartData"), -) -suspend fun ServerWebExchange.awaitMultipartData(): MultiValueMap = - this.multipartData.awaitSingle() - -/** - * Coroutines variant of [ServerWebExchange.getPrincipal]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Deprecated( - message = "Use the variant with the org.springframework.web.server package instead.", - ReplaceWith("awaitPrincipal()", "org.springframework.web.server.awaitPrincipal"), -) -suspend fun ServerWebExchange.awaitPrincipal(): T = - this.getPrincipal().awaitSingle() - -/** - * Coroutines variant of [ServerWebExchange.getSession]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Deprecated( - message = "Use the variant with the org.springframework.web.server package instead.", - ReplaceWith("awaitSession()", "org.springframework.web.server.awaitSession"), -) -suspend fun ServerWebExchange.awaitSession(): WebSession = - this.session.awaitSingle() - -/** - * Coroutines variant of [ServerWebExchange.Builder.principal]. - * - * @author Sebastien Deleuze - * @since 5.2 - */ -@Deprecated( - message = "Use the variant with the org.springframework.web.server package instead.", - ReplaceWith("principal(supplier)", "org.springframework.web.server.principal"), -) -fun ServerWebExchange.Builder.principal(supplier: suspend () -> Principal): ServerWebExchange.Builder - = principal(mono(Dispatchers.Unconfined) { supplier.invoke() }) 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 fc2d4f5fa8c..e754d518da6 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 @@ -327,7 +327,7 @@ class DefaultClientResponseTests { WebClientResponseException exception = resultMono.block(); assertThat(exception.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(exception.getMessage()).isEqualTo("404 Not Found from UNKNOWN https://example.org:9999/app/path"); - assertThat(exception.getHeaders().asMultiValueMap()).containsExactly(entry("Content-Type", List.of("text/plain"))); + assertThat(exception.getHeaders().containsHeaderValue("Content-Type", "text/plain")).isTrue(); assertThat(exception.getResponseBodyAsByteArray()).isEqualTo(bytes); } @@ -387,7 +387,7 @@ class DefaultClientResponseTests { WebClientResponseException exception = (WebClientResponseException) t; assertThat(exception.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(exception.getMessage()).isEqualTo("404 Not Found"); - assertThat(exception.getHeaders().asMultiValueMap()).containsExactly(entry("Content-Type",List.of("text/plain"))); + assertThat(exception.getHeaders().containsHeaderValue("Content-Type", "text/plain")); assertThat(exception.getResponseBodyAsByteArray()).isEqualTo(bytes); }) .verify(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index 3c7fa0b21df..c9abd26139f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.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. @@ -135,35 +135,6 @@ public class DefaultWebClientTests { assertThat(request.cookies().getFirst("id")).isEqualTo("123"); } - @Test - @SuppressWarnings("deprecation") - public void contextFromThreadLocal() { - WebClient client = this.builder - .filter((request, next) -> - // Async, continue on different thread - Mono.delay(Duration.ofMillis(10)).then(next.exchange(request))) - .filter((request, next) -> - Mono.deferContextual(contextView -> { - String fooValue = contextView.get("foo"); - return next.exchange(ClientRequest.from(request).header("foo", fooValue).build()); - })) - .build(); - - ThreadLocal fooHolder = new ThreadLocal<>(); - fooHolder.set("bar"); - try { - client.get().uri("/path") - .context(context -> context.put("foo", fooHolder.get())) - .retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10)); - } - finally { - fooHolder.remove(); - } - - ClientRequest request = verifyAndGetRequest(); - assertThat(request.headers().getFirst("foo")).isEqualTo("bar"); - } - @Test void httpRequest() { this.builder.build().get().uri("/path") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java index e9ff0e264af..73149542b55 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.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. @@ -123,44 +123,6 @@ class ExchangeFilterFunctionsTests { ExchangeFilterFunctions.basicAuthentication("foo", "\ud83d\udca9").filter(request, exchange)); } - @Test - @SuppressWarnings("deprecation") - public void basicAuthenticationAttributes() { - ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL) - .attributes(org.springframework.web.reactive.function.client.ExchangeFilterFunctions - .Credentials.basicAuthenticationCredentials("foo", "bar")) - .build(); - ClientResponse response = mock(); - - ExchangeFunction exchange = r -> { - assertThat(r.headers().containsHeader(HttpHeaders.AUTHORIZATION)).isTrue(); - assertThat(r.headers().getFirst(HttpHeaders.AUTHORIZATION)).startsWith("Basic "); - return Mono.just(response); - }; - - ExchangeFilterFunction auth = ExchangeFilterFunctions.basicAuthentication(); - assertThat(request.headers().containsHeader(HttpHeaders.AUTHORIZATION)).isFalse(); - ClientResponse result = auth.filter(request, exchange).block(); - assertThat(result).isEqualTo(response); - } - - @Test - @SuppressWarnings("deprecation") - public void basicAuthenticationAbsentAttributes() { - ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); - ClientResponse response = mock(); - - ExchangeFunction exchange = r -> { - assertThat(r.headers().containsHeader(HttpHeaders.AUTHORIZATION)).isFalse(); - return Mono.just(response); - }; - - ExchangeFilterFunction auth = ExchangeFilterFunctions.basicAuthentication(); - assertThat(request.headers().containsHeader(HttpHeaders.AUTHORIZATION)).isFalse(); - ClientResponse result = auth.filter(request, exchange).block(); - assertThat(result).isEqualTo(response); - } - @Test void statusHandlerMatch() { ClientRequest request = ClientRequest.create(HttpMethod.GET, DEFAULT_URL).build(); 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 7b4f2567e4c..1590ff68287 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 @@ -601,7 +601,6 @@ class WebClientIntegrationTests { assertThat(throwable).isInstanceOf(WebClientResponseException.class); WebClientResponseException ex = (WebClientResponseException) throwable; assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(ex.getRawStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(ex.getStatusText()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); assertThat(ex.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); assertThat(ex.getResponseBodyAsString()).isEqualTo(errorMessage); @@ -710,7 +709,6 @@ class WebClientIntegrationTests { assertThat(throwable).isInstanceOf(UnknownHttpStatusCodeException.class); UnknownHttpStatusCodeException ex = (UnknownHttpStatusCodeException) throwable; assertThat(ex.getMessage()).isEqualTo(("Unknown status code ["+errorStatus+"]")); - assertThat(ex.getRawStatusCode()).isEqualTo(errorStatus); assertThat(ex.getStatusText()).isEmpty(); assertThat(ex.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN); assertThat(ex.getResponseBodyAsString()).isEqualTo(errorMessage); diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt index 5e1673ab8a0..048b472676f 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt @@ -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. @@ -95,16 +95,6 @@ class WebClientExtensionsTests { verify { responseSpec.bodyToFlux(object : ParameterizedTypeReference>() {}) } } - @Test - @Suppress("DEPRECATION") - fun awaitExchange() { - val response = mockk() - every { requestBodySpec.exchange() } returns Mono.just(response) - runBlocking { - assertThat(requestBodySpec.awaitExchange()).isEqualTo(response) - } - } - @Test fun `awaitExchange with function parameter`() { val foo = mockk()