Upgraded to Apache HttpComponents HttpClient 4.3.1 and HttpAsyncClient 4.0 GA, as well as Jackson 2.2.2
This commit is contained in:
20
build.gradle
20
build.gradle
@@ -98,7 +98,7 @@ configure(allprojects) { project ->
|
||||
"http://ehcache.org/apidocs/",
|
||||
"http://quartz-scheduler.org/api/2.1.7/",
|
||||
"http://jackson.codehaus.org/1.9.12/javadoc/",
|
||||
"http://fasterxml.github.com/jackson-core/javadoc/2.2.0/",
|
||||
"http://fasterxml.github.com/jackson-core/javadoc/2.2.2/",
|
||||
] as String[]
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ project("spring-messaging") {
|
||||
compile(project(":spring-context"))
|
||||
optional(project(":spring-websocket"))
|
||||
optional(project(":spring-webmvc"))
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
optional("org.projectreactor:reactor-core:1.0.0.BUILD-SNAPSHOT")
|
||||
optional("org.projectreactor:reactor-tcp:1.0.0.BUILD-SNAPSHOT")
|
||||
optional("org.eclipse.jetty.websocket:websocket-server:9.1.0.RC0") {
|
||||
@@ -483,7 +483,7 @@ project("spring-jms") {
|
||||
optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1")
|
||||
optional("javax.resource:connector-api:1.5")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,10 +555,10 @@ project("spring-web") {
|
||||
optional("com.caucho:hessian:4.0.7")
|
||||
optional("rome:rome:1.0")
|
||||
optional("commons-fileupload:commons-fileupload:1.3")
|
||||
optional("org.apache.httpcomponents:httpclient:4.3-beta2")
|
||||
optional("org.apache.httpcomponents:httpasyncclient:4.0-beta4")
|
||||
optional("org.apache.httpcomponents:httpclient:4.3.1")
|
||||
optional("org.apache.httpcomponents:httpasyncclient:4.0")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
optional("taglibs:standard:1.1.2")
|
||||
optional("org.eclipse.jetty:jetty-servlet:9.1.0.RC0") {
|
||||
exclude group: "javax.servlet", module: "javax.servlet-api"
|
||||
@@ -600,7 +600,7 @@ project("spring-websocket") {
|
||||
exclude group: "javax.servlet", module: "javax.servlet"
|
||||
}
|
||||
optional("org.eclipse.jetty.websocket:websocket-client:9.1.0.RC0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
|
||||
testCompile("org.apache.tomcat.embed:tomcat-embed-core:8.0.0-RC5")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
@@ -675,7 +675,7 @@ project("spring-webmvc") {
|
||||
optional("velocity-tools:velocity-tools-view:1.4")
|
||||
optional("org.freemarker:freemarker:2.3.19")
|
||||
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
provided("javax.servlet:jstl:1.2")
|
||||
provided("javax.servlet:javax.servlet-api:3.0.1")
|
||||
provided("javax.servlet.jsp:jsp-api:2.1")
|
||||
@@ -701,7 +701,7 @@ project("spring-webmvc") {
|
||||
testCompile("commons-fileupload:commons-fileupload:1.2")
|
||||
testCompile("commons-io:commons-io:1.3")
|
||||
testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
|
||||
testCompile("org.apache.httpcomponents:httpclient:4.3-beta2")
|
||||
testCompile("org.apache.httpcomponents:httpclient:4.3.1")
|
||||
testCompile("joda-time:joda-time:2.2")
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ project("spring-test-mvc") {
|
||||
testCompile("javax.servlet:jstl:1.2")
|
||||
testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
|
||||
testCompile("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
|
||||
testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.0")
|
||||
testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.2")
|
||||
testCompile(project(":spring-context-support"))
|
||||
testCompile(project(":spring-oxm"))
|
||||
testCompile("com.thoughtworks.xstream:xstream:1.4.4")
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClients;
|
||||
import org.apache.http.nio.client.HttpAsyncClient;
|
||||
import org.apache.http.nio.reactor.IOReactorStatus;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Asynchronous extension of the {@link HttpComponentsClientHttpRequestFactory}. Uses
|
||||
* <a href="http://hc.apache.org/httpcomponents-asyncclient-dev/">Apache HttpComponents
|
||||
* HttpAsyncClient</a> to create requests.
|
||||
* HttpAsyncClient 4.0</a> to create requests.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
@@ -75,13 +75,15 @@ public class HttpComponentsAsyncClientHttpRequestFactory
|
||||
* @param httpClient the HttpClient instance to use for this request factory
|
||||
* @param httpAsyncClient the HttpAsyncClient instance to use for this request factory
|
||||
*/
|
||||
public HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient,
|
||||
CloseableHttpAsyncClient httpAsyncClient) {
|
||||
public HttpComponentsAsyncClientHttpRequestFactory(
|
||||
CloseableHttpClient httpClient, CloseableHttpAsyncClient httpAsyncClient) {
|
||||
|
||||
super(httpClient);
|
||||
Assert.notNull(httpAsyncClient, "'httpAsyncClient' must not be null");
|
||||
this.httpAsyncClient = httpAsyncClient;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the {@code HttpClient} used for
|
||||
* {@linkplain #createAsyncRequest(java.net.URI, org.springframework.http.HttpMethod) asynchronous execution}.
|
||||
@@ -105,7 +107,7 @@ public class HttpComponentsAsyncClientHttpRequestFactory
|
||||
|
||||
private void startAsyncClient() {
|
||||
CloseableHttpAsyncClient asyncClient = getHttpAsyncClient();
|
||||
if (asyncClient.getStatus() != IOReactorStatus.ACTIVE) {
|
||||
if (!asyncClient.isRunning()) {
|
||||
asyncClient.start();
|
||||
}
|
||||
}
|
||||
@@ -145,4 +147,5 @@ public class HttpComponentsAsyncClientHttpRequestFactory
|
||||
getHttpAsyncClient().close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,12 +52,13 @@ import org.springframework.util.Assert;
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.1
|
||||
*/
|
||||
public class HttpComponentsClientHttpRequestFactory
|
||||
implements ClientHttpRequestFactory, DisposableBean {
|
||||
public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequestFactory, DisposableBean {
|
||||
|
||||
private CloseableHttpClient httpClient;
|
||||
|
||||
private int connectTimeout;
|
||||
|
||||
private int socketTimeout;
|
||||
private CloseableHttpClient httpClient;
|
||||
|
||||
private boolean bufferRequestBody = true;
|
||||
|
||||
@@ -80,6 +81,7 @@ public class HttpComponentsClientHttpRequestFactory
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the {@code HttpClient} used for
|
||||
* {@linkplain #createRequest(URI, HttpMethod) synchronous execution}.
|
||||
@@ -118,7 +120,6 @@ public class HttpComponentsClientHttpRequestFactory
|
||||
|
||||
/**
|
||||
* Indicates whether this request factory should buffer the request body internally.
|
||||
*
|
||||
* <p>Default is {@code true}. When sending large amounts of data via POST or PUT, it is
|
||||
* recommended to change this property to {@code false}, so as not to run out of memory.
|
||||
*/
|
||||
@@ -126,20 +127,11 @@ public class HttpComponentsClientHttpRequestFactory
|
||||
this.bufferRequestBody = bufferRequestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this request factory should buffer the request body internally.
|
||||
*/
|
||||
public boolean isBufferRequestBody() {
|
||||
return bufferRequestBody;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
|
||||
CloseableHttpClient client = getHttpClient();
|
||||
Assert.state(client != null,
|
||||
"Synchronous execution requires an HttpClient to be set");
|
||||
Assert.state(client != null, "Synchronous execution requires an HttpClient to be set");
|
||||
HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
|
||||
postProcessHttpRequest(httpRequest);
|
||||
HttpContext context = createHttpContext(httpMethod, uri);
|
||||
@@ -159,13 +151,14 @@ public class HttpComponentsClientHttpRequestFactory
|
||||
.setConnectTimeout(this.connectTimeout)
|
||||
.setSocketTimeout(this.socketTimeout)
|
||||
.build();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
config = RequestConfig.DEFAULT;
|
||||
}
|
||||
}
|
||||
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
|
||||
}
|
||||
if (bufferRequestBody) {
|
||||
if (this.bufferRequestBody) {
|
||||
return new HttpComponentsClientHttpRequest(client, httpRequest, context);
|
||||
}
|
||||
else {
|
||||
@@ -229,7 +222,7 @@ public class HttpComponentsClientHttpRequestFactory
|
||||
*/
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
httpClient.close();
|
||||
this.httpClient.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user