Skip to content

Commit 957f503

Browse files
committed
Deprecated AsyncRestTemplate and related types
This commit deprecates `AsyncRestTemplate` and related types (`AsyncClientHttpRequestFactory` etc.) in favor of the Spring 5.0 `WebClient`. Issue: SPR-15294
1 parent c5bcefb commit 957f503

26 files changed

+194
-160
lines changed

spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,21 +20,22 @@
2020
import java.net.URI;
2121

2222
import org.springframework.http.HttpMethod;
23-
import org.springframework.http.client.AsyncClientHttpRequest;
2423
import org.springframework.http.client.ClientHttpResponse;
2524
import org.springframework.util.concurrent.ListenableFuture;
2625
import org.springframework.util.concurrent.SettableListenableFuture;
2726

2827
/**
2928
* An extension of {@link MockClientHttpRequest} that also implements
30-
* {@link AsyncClientHttpRequest} by wrapping the response in a
29+
* {@link org.springframework.http.client.AsyncClientHttpRequest} by wrapping the response in a
3130
* {@link SettableListenableFuture}.
3231
*
3332
* @author Rossen Stoyanchev
3433
* @author Sam Brannen
3534
* @since 4.1
35+
* @deprecated as of Spring 5.0, with no direct replacement
3636
*/
37-
public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements AsyncClientHttpRequest {
37+
@Deprecated
38+
public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements org.springframework.http.client.AsyncClientHttpRequest {
3839

3940
public MockAsyncClientHttpRequest() {
4041
}

spring-test/src/main/java/org/springframework/test/web/client/MockRestServiceServer.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,14 +20,10 @@
2020
import java.net.URI;
2121

2222
import org.springframework.http.HttpMethod;
23-
import org.springframework.http.client.AsyncClientHttpRequest;
24-
import org.springframework.http.client.AsyncClientHttpRequestFactory;
2523
import org.springframework.http.client.ClientHttpRequest;
2624
import org.springframework.http.client.ClientHttpRequestFactory;
2725
import org.springframework.http.client.ClientHttpResponse;
28-
import org.springframework.mock.http.client.MockAsyncClientHttpRequest;
2926
import org.springframework.util.Assert;
30-
import org.springframework.web.client.AsyncRestTemplate;
3127
import org.springframework.web.client.RestTemplate;
3228
import org.springframework.web.client.support.RestGatewaySupport;
3329

@@ -65,6 +61,7 @@
6561
* @author Rossen Stoyanchev
6662
* @since 3.2
6763
*/
64+
@SuppressWarnings("deprecation")
6865
public class MockRestServiceServer {
6966

7067
private final RequestExpectationManager expectationManager;
@@ -139,7 +136,7 @@ public static MockRestServiceServerBuilder bindTo(RestTemplate restTemplate) {
139136
* to reply to the given {@code AsyncRestTemplate}.
140137
* @since 4.3
141138
*/
142-
public static MockRestServiceServerBuilder bindTo(AsyncRestTemplate asyncRestTemplate) {
139+
public static MockRestServiceServerBuilder bindTo(org.springframework.web.client.AsyncRestTemplate asyncRestTemplate) {
143140
return new DefaultBuilder(asyncRestTemplate);
144141
}
145142

@@ -168,7 +165,7 @@ public static MockRestServiceServer createServer(RestTemplate restTemplate) {
168165
* @param asyncRestTemplate the AsyncRestTemplate to set up for mock testing
169166
* @return the created mock server
170167
*/
171-
public static MockRestServiceServer createServer(AsyncRestTemplate asyncRestTemplate) {
168+
public static MockRestServiceServer createServer(org.springframework.web.client.AsyncRestTemplate asyncRestTemplate) {
172169
return bindTo(asyncRestTemplate).build();
173170
}
174171

@@ -215,7 +212,7 @@ private static class DefaultBuilder implements MockRestServiceServerBuilder {
215212

216213
private final RestTemplate restTemplate;
217214

218-
private final AsyncRestTemplate asyncRestTemplate;
215+
private final org.springframework.web.client.AsyncRestTemplate asyncRestTemplate;
219216

220217
private boolean ignoreExpectOrder;
221218

@@ -225,7 +222,7 @@ public DefaultBuilder(RestTemplate restTemplate) {
225222
this.asyncRestTemplate = null;
226223
}
227224

228-
public DefaultBuilder(AsyncRestTemplate asyncRestTemplate) {
225+
public DefaultBuilder(org.springframework.web.client.AsyncRestTemplate asyncRestTemplate) {
229226
Assert.notNull(asyncRestTemplate, "AsyncRestTemplate must not be null");
230227
this.restTemplate = null;
231228
this.asyncRestTemplate = asyncRestTemplate;
@@ -266,23 +263,24 @@ public MockRestServiceServer build(RequestExpectationManager manager) {
266263
* Mock ClientHttpRequestFactory that creates requests by iterating
267264
* over the list of expected {@link DefaultRequestExpectation}'s.
268265
*/
269-
private class MockClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory {
266+
@SuppressWarnings("deprecation")
267+
private class MockClientHttpRequestFactory implements ClientHttpRequestFactory, org.springframework.http.client.AsyncClientHttpRequestFactory {
270268

271269
@Override
272270
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) {
273271
return createRequestInternal(uri, httpMethod);
274272
}
275273

276274
@Override
277-
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) {
275+
public org.springframework.http.client.AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) {
278276
return createRequestInternal(uri, httpMethod);
279277
}
280278

281-
private MockAsyncClientHttpRequest createRequestInternal(URI uri, HttpMethod method) {
279+
private org.springframework.mock.http.client.MockAsyncClientHttpRequest createRequestInternal(URI uri, HttpMethod method) {
282280
Assert.notNull(uri, "'uri' must not be null");
283281
Assert.notNull(method, "'httpMethod' must not be null");
284282

285-
return new MockAsyncClientHttpRequest(method, uri) {
283+
return new org.springframework.mock.http.client.MockAsyncClientHttpRequest(method, uri) {
286284

287285
@Override
288286
protected ClientHttpResponse executeInternal() throws IOException {

spring-web/src/main/java/org/springframework/http/client/AbstractAsyncClientHttpRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@
2929
*
3030
* @author Arjen Poutsma
3131
* @since 4.0
32+
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.AbstractClientHttpRequest}
3233
*/
34+
@Deprecated
3335
abstract class AbstractAsyncClientHttpRequest implements AsyncClientHttpRequest {
3436

3537
private final HttpHeaders headers = new HttpHeaders();

spring-web/src/main/java/org/springframework/http/client/AbstractBufferingAsyncClientHttpRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@
2929
*
3030
* @author Arjen Poutsma
3131
* @since 4.0
32+
* @deprecated as of Spring 5.0, with no direct replacement
3233
*/
34+
@Deprecated
3335
abstract class AbstractBufferingAsyncClientHttpRequest extends AbstractAsyncClientHttpRequest {
3436

3537
private ByteArrayOutputStream bufferedOutput = new ByteArrayOutputStream(1024);

spring-web/src/main/java/org/springframework/http/client/AsyncClientHttpRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,9 @@
3232
* @author Arjen Poutsma
3333
* @since 4.0
3434
* @see AsyncClientHttpRequestFactory#createAsyncRequest
35+
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ClientRequest}
3536
*/
37+
@Deprecated
3638
public interface AsyncClientHttpRequest extends HttpRequest, HttpOutputMessage {
3739

3840
/**

spring-web/src/main/java/org/springframework/http/client/AsyncClientHttpRequestExecution.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,17 +31,19 @@
3131
* @author Rossen Stoyanchev
3232
* @since 4.3
3333
* @see AsyncClientHttpRequestInterceptor
34+
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
3435
*/
36+
@Deprecated
3537
public interface AsyncClientHttpRequestExecution {
3638

37-
/**
38-
* Resume the request execution by invoking the next interceptor in the chain
39-
* or executing the request to the remote service.
40-
* @param request the HTTP request, containing the HTTP method and headers
41-
* @param body the body of the request
42-
* @return a corresponding future handle
43-
* @throws IOException in case of I/O errors
44-
*/
45-
ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException;
39+
/**
40+
* Resume the request execution by invoking the next interceptor in the chain
41+
* or executing the request to the remote service.
42+
* @param request the HTTP request, containing the HTTP method and headers
43+
* @param body the body of the request
44+
* @return a corresponding future handle
45+
* @throws IOException in case of I/O errors
46+
*/
47+
ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException;
4648

4749
}

spring-web/src/main/java/org/springframework/http/client/AsyncClientHttpRequestFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,9 @@
2727
*
2828
* @author Arjen Poutsma
2929
* @since 4.0
30+
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ClientHttpConnector}
3031
*/
32+
@Deprecated
3133
public interface AsyncClientHttpRequestFactory {
3234

3335
/**

spring-web/src/main/java/org/springframework/http/client/AsyncClientHttpRequestInterceptor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020

2121
import org.springframework.http.HttpRequest;
22-
import org.springframework.http.client.support.InterceptingAsyncHttpAccessor;
2322
import org.springframework.util.concurrent.ListenableFuture;
2423

2524
/**
@@ -36,8 +35,10 @@
3635
* @author Rossen Stoyanchev
3736
* @since 4.3
3837
* @see org.springframework.web.client.AsyncRestTemplate
39-
* @see InterceptingAsyncHttpAccessor
38+
* @see org.springframework.http.client.support.InterceptingAsyncHttpAccessor
39+
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
4040
*/
41+
@Deprecated
4142
public interface AsyncClientHttpRequestInterceptor {
4243

4344
/**

spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,9 @@
4949
* @author Arjen Poutsma
5050
* @since 4.0
5151
* @see HttpComponentsClientHttpRequestFactory#createRequest
52+
* @deprecated as of Spring 5.0, with no direct replacement
5253
*/
54+
@Deprecated
5355
final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest {
5456

5557
private final HttpAsyncClient httpClient;

spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,9 @@
4343
* @author Stephane Nicoll
4444
* @since 4.0
4545
* @see HttpAsyncClient
46+
* @deprecated as of Spring 5.0, with no direct replacement
4647
*/
48+
@Deprecated
4749
public class HttpComponentsAsyncClientHttpRequestFactory extends HttpComponentsClientHttpRequestFactory
4850
implements AsyncClientHttpRequestFactory, InitializingBean {
4951

0 commit comments

Comments
 (0)