Skip to content

Commit 84bc474

Browse files
jhoellerunknown
authored andcommitted
Upgraded to Apache HttpComponents HttpClient 4.3.1 and HttpAsyncClient 4.0 GA, as well as Jackson 2.2.2
1 parent 6e418fe commit 84bc474

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ configure(allprojects) { project ->
9898
"http://ehcache.org/apidocs/",
9999
"http://quartz-scheduler.org/api/2.1.7/",
100100
"http://jackson.codehaus.org/1.9.12/javadoc/",
101-
"http://fasterxml.github.com/jackson-core/javadoc/2.2.0/",
101+
"http://fasterxml.github.com/jackson-core/javadoc/2.2.2/",
102102
] as String[]
103103
}
104104

@@ -385,7 +385,7 @@ project("spring-messaging") {
385385
compile(project(":spring-context"))
386386
optional(project(":spring-websocket"))
387387
optional(project(":spring-webmvc"))
388-
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
388+
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
389389
optional("org.projectreactor:reactor-core:1.0.0.BUILD-SNAPSHOT")
390390
optional("org.projectreactor:reactor-tcp:1.0.0.BUILD-SNAPSHOT")
391391
optional("org.eclipse.jetty.websocket:websocket-server:9.1.0.RC0") {
@@ -483,7 +483,7 @@ project("spring-jms") {
483483
optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1")
484484
optional("javax.resource:connector-api:1.5")
485485
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
486-
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
486+
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
487487
}
488488
}
489489

@@ -555,10 +555,10 @@ project("spring-web") {
555555
optional("com.caucho:hessian:4.0.7")
556556
optional("rome:rome:1.0")
557557
optional("commons-fileupload:commons-fileupload:1.3")
558-
optional("org.apache.httpcomponents:httpclient:4.3-beta2")
559-
optional("org.apache.httpcomponents:httpasyncclient:4.0-beta4")
558+
optional("org.apache.httpcomponents:httpclient:4.3.1")
559+
optional("org.apache.httpcomponents:httpasyncclient:4.0")
560560
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
561-
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
561+
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
562562
optional("taglibs:standard:1.1.2")
563563
optional("org.eclipse.jetty:jetty-servlet:9.1.0.RC0") {
564564
exclude group: "javax.servlet", module: "javax.servlet-api"
@@ -600,7 +600,7 @@ project("spring-websocket") {
600600
exclude group: "javax.servlet", module: "javax.servlet"
601601
}
602602
optional("org.eclipse.jetty.websocket:websocket-client:9.1.0.RC0")
603-
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
603+
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
604604
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
605605
testCompile("org.apache.tomcat.embed:tomcat-embed-core:8.0.0-RC5")
606606
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
@@ -675,7 +675,7 @@ project("spring-webmvc") {
675675
optional("velocity-tools:velocity-tools-view:1.4")
676676
optional("org.freemarker:freemarker:2.3.19")
677677
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
678-
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
678+
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
679679
provided("javax.servlet:jstl:1.2")
680680
provided("javax.servlet:javax.servlet-api:3.0.1")
681681
provided("javax.servlet.jsp:jsp-api:2.1")
@@ -701,7 +701,7 @@ project("spring-webmvc") {
701701
testCompile("commons-fileupload:commons-fileupload:1.2")
702702
testCompile("commons-io:commons-io:1.3")
703703
testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
704-
testCompile("org.apache.httpcomponents:httpclient:4.3-beta2")
704+
testCompile("org.apache.httpcomponents:httpclient:4.3.1")
705705
testCompile("joda-time:joda-time:2.2")
706706
}
707707

@@ -824,7 +824,7 @@ project("spring-test-mvc") {
824824
testCompile("javax.servlet:jstl:1.2")
825825
testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
826826
testCompile("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
827-
testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.0")
827+
testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.2")
828828
testCompile(project(":spring-context-support"))
829829
testCompile(project(":spring-oxm"))
830830
testCompile("com.thoughtworks.xstream:xstream:1.4.4")

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
2929
import org.apache.http.impl.nio.client.HttpAsyncClients;
3030
import org.apache.http.nio.client.HttpAsyncClient;
31-
import org.apache.http.nio.reactor.IOReactorStatus;
3231
import org.apache.http.protocol.HttpContext;
32+
3333
import org.springframework.beans.factory.InitializingBean;
3434
import org.springframework.http.HttpMethod;
3535
import org.springframework.util.Assert;
3636

3737
/**
3838
* Asynchronous extension of the {@link HttpComponentsClientHttpRequestFactory}. Uses
3939
* <a href="http://hc.apache.org/httpcomponents-asyncclient-dev/">Apache HttpComponents
40-
* HttpAsyncClient</a> to create requests.
40+
* HttpAsyncClient 4.0</a> to create requests.
4141
*
4242
* @author Arjen Poutsma
4343
* @since 4.0
@@ -75,13 +75,15 @@ public HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpAsyncClient http
7575
* @param httpClient the HttpClient instance to use for this request factory
7676
* @param httpAsyncClient the HttpAsyncClient instance to use for this request factory
7777
*/
78-
public HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient,
79-
CloseableHttpAsyncClient httpAsyncClient) {
78+
public HttpComponentsAsyncClientHttpRequestFactory(
79+
CloseableHttpClient httpClient, CloseableHttpAsyncClient httpAsyncClient) {
80+
8081
super(httpClient);
8182
Assert.notNull(httpAsyncClient, "'httpAsyncClient' must not be null");
8283
this.httpAsyncClient = httpAsyncClient;
8384
}
8485

86+
8587
/**
8688
* Set the {@code HttpClient} used for
8789
* {@linkplain #createAsyncRequest(java.net.URI, org.springframework.http.HttpMethod) asynchronous execution}.
@@ -105,7 +107,7 @@ public void afterPropertiesSet() {
105107

106108
private void startAsyncClient() {
107109
CloseableHttpAsyncClient asyncClient = getHttpAsyncClient();
108-
if (asyncClient.getStatus() != IOReactorStatus.ACTIVE) {
110+
if (!asyncClient.isRunning()) {
109111
asyncClient.start();
110112
}
111113
}
@@ -145,4 +147,5 @@ public void destroy() throws Exception {
145147
getHttpAsyncClient().close();
146148
}
147149
}
150+
148151
}

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@
5252
* @author Arjen Poutsma
5353
* @since 3.1
5454
*/
55-
public class HttpComponentsClientHttpRequestFactory
56-
implements ClientHttpRequestFactory, DisposableBean {
55+
public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequestFactory, DisposableBean {
56+
57+
private CloseableHttpClient httpClient;
5758

5859
private int connectTimeout;
60+
5961
private int socketTimeout;
60-
private CloseableHttpClient httpClient;
6162

6263
private boolean bufferRequestBody = true;
6364

@@ -80,6 +81,7 @@ public HttpComponentsClientHttpRequestFactory(CloseableHttpClient httpClient) {
8081
this.httpClient = httpClient;
8182
}
8283

84+
8385
/**
8486
* Set the {@code HttpClient} used for
8587
* {@linkplain #createRequest(URI, HttpMethod) synchronous execution}.
@@ -118,28 +120,18 @@ public void setReadTimeout(int timeout) {
118120

119121
/**
120122
* Indicates whether this request factory should buffer the request body internally.
121-
*
122123
* <p>Default is {@code true}. When sending large amounts of data via POST or PUT, it is
123124
* recommended to change this property to {@code false}, so as not to run out of memory.
124125
*/
125126
public void setBufferRequestBody(boolean bufferRequestBody) {
126127
this.bufferRequestBody = bufferRequestBody;
127128
}
128129

129-
/**
130-
* Indicates whether this request factory should buffer the request body internally.
131-
*/
132-
public boolean isBufferRequestBody() {
133-
return bufferRequestBody;
134-
}
135-
136-
137130

138131
@Override
139132
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
140133
CloseableHttpClient client = getHttpClient();
141-
Assert.state(client != null,
142-
"Synchronous execution requires an HttpClient to be set");
134+
Assert.state(client != null, "Synchronous execution requires an HttpClient to be set");
143135
HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
144136
postProcessHttpRequest(httpRequest);
145137
HttpContext context = createHttpContext(httpMethod, uri);
@@ -159,13 +151,14 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
159151
.setConnectTimeout(this.connectTimeout)
160152
.setSocketTimeout(this.socketTimeout)
161153
.build();
162-
} else {
154+
}
155+
else {
163156
config = RequestConfig.DEFAULT;
164157
}
165158
}
166159
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
167160
}
168-
if (bufferRequestBody) {
161+
if (this.bufferRequestBody) {
169162
return new HttpComponentsClientHttpRequest(client, httpRequest, context);
170163
}
171164
else {
@@ -229,7 +222,7 @@ protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
229222
*/
230223
@Override
231224
public void destroy() throws Exception {
232-
httpClient.close();
225+
this.httpClient.close();
233226
}
234227

235228
}

0 commit comments

Comments
 (0)