From f394c8aa2a87bed84ca5e0202c95b13a99c3fffb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 16 Sep 2014 15:03:21 +0200 Subject: [PATCH] Polishing Issue: SPR-12196 --- .../client/AbstractClientHttpRequest.java | 8 ++--- .../SimpleClientHttpRequestFactory.java | 33 ++++++++----------- .../http/client/SimpleClientHttpResponse.java | 4 +-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequest.java index 0b2c359549..4603fc4536 100644 --- a/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequest.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. @@ -23,7 +23,8 @@ import org.springframework.http.HttpHeaders; import org.springframework.util.Assert; /** - * Abstract base for {@link ClientHttpRequest} that makes sure that headers and body are not written multiple times. + * Abstract base for {@link ClientHttpRequest} that makes sure that headers + * and body are not written multiple times. * * @author Arjen Poutsma * @since 3.0 @@ -55,8 +56,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest { } /** - * Asserts that this request has not been {@linkplain #execute() executed} yet. - * + * Assert that this request has not been {@linkplain #execute() executed} yet. * @throws IllegalStateException if this request has been executed */ protected void assertNotExecuted() { diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java index ff67b6e7fa..6f14c1b220 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.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. @@ -28,7 +28,7 @@ import org.springframework.http.HttpMethod; import org.springframework.util.Assert; /** - * {@link ClientHttpRequestFactory} implementation that uses standard J2SE facilities. + * {@link ClientHttpRequestFactory} implementation that uses standard JDK facilities. * * @author Arjen Poutsma * @author Juergen Hoeller @@ -36,8 +36,7 @@ import org.springframework.util.Assert; * @see java.net.HttpURLConnection * @see HttpComponentsClientHttpRequestFactory */ -public class SimpleClientHttpRequestFactory - implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { +public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { private static final int DEFAULT_CHUNK_SIZE = 4096; @@ -111,14 +110,12 @@ public class SimpleClientHttpRequestFactory } /** - * Set if the underlying URLConnection can be set to 'output streaming' mode. When - * output streaming is enabled, authentication and redirection cannot be handled - * automatically. If output streaming is disabled the - * {@link HttpURLConnection#setFixedLengthStreamingMode(int) - * setFixedLengthStreamingMode} and - * {@link HttpURLConnection#setChunkedStreamingMode(int) setChunkedStreamingMode} - * methods of the underlying connection will never be called. - *

Default is {@code true}. + * Set if the underlying URLConnection can be set to 'output streaming' mode. + * Default is {@code true}. + *

When output streaming is enabled, authentication and redirection cannot be handled automatically. + * If output streaming is disabled, the {@link HttpURLConnection#setFixedLengthStreamingMode} and + * {@link HttpURLConnection#setChunkedStreamingMode} methods of the underlying connection will never + * be called. * @param outputStreaming if output streaming is enabled */ public void setOutputStreaming(boolean outputStreaming) { @@ -126,15 +123,15 @@ public class SimpleClientHttpRequestFactory } /** - * Sets the task executor for this request factory. Setting this property is required - * for {@linkplain #createAsyncRequest(URI, HttpMethod) creating asynchronous - * request}. + * Set the task executor for this request factory. Setting this property is required + * for {@linkplain #createAsyncRequest(URI, HttpMethod) creating asynchronous requests}. * @param taskExecutor the task executor */ public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; } + @Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { HttpURLConnection connection = openConnection(uri.toURL(), this.proxy); @@ -153,10 +150,8 @@ public class SimpleClientHttpRequestFactory * is required before calling this method. */ @Override - public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) - throws IOException { - Assert.state(this.taskExecutor != null, "Asynchronous execution requires an " + - "AsyncTaskExecutor to be set"); + public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { + Assert.state(this.taskExecutor != null, "Asynchronous execution requires an AsyncTaskExecutor to be set"); HttpURLConnection connection = openConnection(uri.toURL(), this.proxy); prepareConnection(connection, httpMethod.name()); if (this.bufferRequestBody) { diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java index 986a9202f6..cc7e627d0a 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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,7 +24,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.util.StringUtils; /** - * {@link ClientHttpResponse} implementation that uses standard J2SE facilities. + * {@link ClientHttpResponse} implementation that uses standard JDK facilities. * Obtained via {@link SimpleBufferingClientHttpRequest#execute()} and * {@link SimpleStreamingClientHttpRequest#execute()}. *