diff --git a/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingAsyncClientHttpRequest.java index 76658da402..a9bedf9879 100644 --- a/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingAsyncClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -24,24 +24,24 @@ import org.springframework.http.HttpHeaders; import org.springframework.util.concurrent.ListenableFuture; /** - * Abstract base for {@link org.springframework.http.client.ClientHttpRequest} that buffers output in a byte array before sending it over the wire. + * Base implementation of {@link AsyncClientHttpRequest} that buffers output + * in a byte array before sending it over the wire. * * @author Arjen Poutsma - * @since 3.0.6 + * @since 4.0 */ -abstract class AbstractBufferingAsyncClientHttpRequest - extends AbstractAsyncClientHttpRequest { +abstract class AbstractBufferingAsyncClientHttpRequest extends AbstractAsyncClientHttpRequest { private ByteArrayOutputStream bufferedOutput = new ByteArrayOutputStream(); + @Override protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException { return this.bufferedOutput; } @Override - protected ListenableFuture executeInternal(HttpHeaders headers) - throws IOException { + protected ListenableFuture executeInternal(HttpHeaders headers) throws IOException { byte[] bytes = this.bufferedOutput.toByteArray(); if (headers.getContentLength() == -1) { headers.setContentLength(bytes.length); @@ -52,9 +52,7 @@ abstract class AbstractBufferingAsyncClientHttpRequest } /** - * Abstract template method that writes the given headers and content to the HTTP - * request. - * + * Abstract template method that writes the given headers and content to the HTTP request. * @param headers the HTTP headers * @param bufferedOutput the body content * @return the response object for the executed request @@ -62,5 +60,4 @@ abstract class AbstractBufferingAsyncClientHttpRequest protected abstract ListenableFuture executeInternal( HttpHeaders headers, byte[] bufferedOutput) throws IOException; - } diff --git a/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingClientHttpRequest.java index 3048b76009..ab44d94a0a 100644 --- a/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/AbstractBufferingClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2014 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. @@ -23,7 +23,8 @@ import java.io.OutputStream; import org.springframework.http.HttpHeaders; /** - * Abstract base for {@link ClientHttpRequest} that buffers output in a byte array before sending it over the wire. + * Base implementation of {@link ClientHttpRequest} that buffers output + * in a byte array before sending it over the wire. * * @author Arjen Poutsma * @since 3.0.6 @@ -32,6 +33,7 @@ abstract class AbstractBufferingClientHttpRequest extends AbstractClientHttpRequ private ByteArrayOutputStream bufferedOutput = new ByteArrayOutputStream(); + @Override protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException { return this.bufferedOutput; diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java index fe8bb3787e..9aabb66a36 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java @@ -66,8 +66,8 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest /** - * Create a new instance of the {@code HttpComponentsClientHttpRequestFactory} with - * a default {@link HttpClient}. + * Create a new instance of the {@code HttpComponentsClientHttpRequestFactory} + * with a default {@link HttpClient}. */ public HttpComponentsClientHttpRequestFactory() { this(HttpClients.createSystem()); @@ -76,10 +76,8 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest /** * Create a new instance of the {@code HttpComponentsClientHttpRequestFactory} * with the given {@link HttpClient} instance. - *

- * As of Spring Framework 4 the given client is expected to be of type + *

As of Spring Framework 4.0, the given client is expected to be of type * CloseableHttpClient (requiring HttpClient 4.3+). - * * @param httpClient the HttpClient instance to use for this request factory */ public HttpComponentsClientHttpRequestFactory(HttpClient httpClient) { @@ -91,11 +89,8 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest /** * Set the {@code HttpClient} used for - *

- * As of Spring Framework 4 the given client is expected to be of type + *

As of Spring Framework 4.0, the given client is expected to be of type * CloseableHttpClient (requiring HttpClient 4.3+). - * - * {@linkplain #createRequest(URI, HttpMethod) synchronous execution}. */ public void setHttpClient(HttpClient httpClient) { Assert.isInstanceOf(CloseableHttpClient.class, httpClient, "'httpClient' is not of type CloseableHttpClient");