[Git][java-team/httpcomponents-client5][upstream] New upstream version 5.1.2
Markus Koschany (@apo)
gitlab at salsa.debian.org
Fri Nov 19 13:31:47 GMT 2021
Markus Koschany pushed to branch upstream at Debian Java Maintainers / httpcomponents-client5
Commits:
5240642d by Markus Koschany at 2021-11-19T14:14:55+01:00
New upstream version 5.1.2
- - - - -
10 changed files:
- RELEASE_NOTES.txt
- httpclient5-cache/pom.xml
- httpclient5-fluent/pom.xml
- httpclient5-testing/pom.xml
- httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java
- httpclient5-win/pom.xml
- httpclient5/pom.xml
- httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java
- httpclient5/src/main/resources/org/apache/hc/client5/version.properties
- pom.xml
Changes:
=====================================
RELEASE_NOTES.txt
=====================================
@@ -1,4 +1,19 @@
-Release 5.1.1
+Release 5.1.2
+-----------
+
+This is an emergency release that fixes a regression introduced in the previous release
+that can lead to a connection leak when executing requests with a non-repeatable streaming
+entity with the classic (blocking) HttpClient. Async and minimal HttpClient implementations
+are not affected by the regression.
+
+Change Log
+-------------------
+
+* HTTPCLIENT-2184: Fixed regression in the connection reuse logic of the classic (blocking)
+ request execution pipeline.
+
+
+Release 5.1.1
-----------
This release upgrades HttpCore to the latest 5.1 version and fixes a number of issues found
=====================================
httpclient5-cache/pom.xml
=====================================
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
- <version>5.1.1</version>
+ <version>5.1.2</version>
</parent>
<artifactId>httpclient5-cache</artifactId>
<name>Apache HttpClient Cache</name>
=====================================
httpclient5-fluent/pom.xml
=====================================
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
- <version>5.1.1</version>
+ <version>5.1.2</version>
</parent>
<artifactId>httpclient5-fluent</artifactId>
<name>Apache HttpClient Fluent</name>
=====================================
httpclient5-testing/pom.xml
=====================================
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
- <version>5.1.1</version>
+ <version>5.1.2</version>
</parent>
<artifactId>httpclient5-testing</artifactId>
<name>Apache HttpClient Integration Tests</name>
=====================================
httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java
=====================================
@@ -27,12 +27,19 @@
package org.apache.hc.client5.testing.sync;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HeaderElements;
@@ -43,6 +50,7 @@
import org.apache.hc.core5.http.HttpResponseInterceptor;
import org.apache.hc.core5.http.impl.HttpProcessors;
import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.junit.Assert;
@@ -81,6 +89,42 @@ public void testReuseOfPersistentConnections() throws Exception {
Assert.assertTrue(this.connManager.getTotalStats().getAvailable() > 0);
}
+ @Test
+ public void testReuseOfPersistentConnectionsWithStreamedRequestAndResponse() throws Exception {
+ this.connManager.setMaxTotal(5);
+ this.connManager.setDefaultMaxPerRoute(5);
+
+ final HttpHost target = start();
+
+ final WorkerThread[] workers = new WorkerThread[10];
+ for (int i = 0; i < workers.length; i++) {
+ final List<HttpUriRequestBase> requests = new ArrayList<>();
+ for (int j = 0; j < 10; j++) {
+ final HttpPost post = new HttpPost(new URI("/random/2000"));
+ // non-repeatable
+ post.setEntity(new InputStreamEntity(
+ new ByteArrayInputStream("test".getBytes(StandardCharsets.UTF_8)),
+ ContentType.APPLICATION_OCTET_STREAM));
+ requests.add(post);
+ }
+ workers[i] = new WorkerThread(this.httpclient, target, false, requests);
+ }
+
+ for (final WorkerThread worker : workers) {
+ worker.start();
+ }
+ for (final WorkerThread worker : workers) {
+ worker.join(10000);
+ final Exception ex = worker.getException();
+ if (ex != null) {
+ throw ex;
+ }
+ }
+
+ // Expect some connection in the pool
+ Assert.assertTrue(this.connManager.getTotalStats().getAvailable() > 0);
+ }
+
private static class AlwaysCloseConn implements HttpResponseInterceptor {
@Override
@@ -196,11 +240,10 @@ public void testKeepAliveHeaderRespected() throws Exception {
private static class WorkerThread extends Thread {
- private final URI requestURI;
private final HttpHost target;
private final CloseableHttpClient httpclient;
- private final int repetitions;
private final boolean forceClose;
+ private final List<HttpUriRequestBase> requests;
private volatile Exception exception;
@@ -212,22 +255,35 @@ public WorkerThread(
final boolean forceClose) {
super();
this.httpclient = httpclient;
- this.requestURI = requestURI;
this.target = target;
- this.repetitions = repetitions;
this.forceClose = forceClose;
+ this.requests = new ArrayList<>(repetitions);
+ for (int i = 0; i < repetitions; i++) {
+ requests.add(new HttpGet(requestURI));
+ }
+ }
+
+ public WorkerThread(
+ final CloseableHttpClient httpclient,
+ final HttpHost target,
+ final boolean forceClose,
+ final List<HttpUriRequestBase> requests) {
+ super();
+ this.httpclient = httpclient;
+ this.target = target;
+ this.forceClose = forceClose;
+ this.requests = requests;
}
@Override
public void run() {
try {
- for (int i = 0; i < this.repetitions; i++) {
- final HttpGet httpget = new HttpGet(this.requestURI);
+ for (final HttpUriRequestBase request : requests) {
final ClassicHttpResponse response = this.httpclient.execute(
this.target,
- httpget);
+ request);
if (this.forceClose) {
- httpget.cancel();
+ request.cancel();
} else {
EntityUtils.consume(response.getEntity());
}
=====================================
httpclient5-win/pom.xml
=====================================
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
- <version>5.1.1</version>
+ <version>5.1.2</version>
</parent>
<artifactId>httpclient5-win</artifactId>
<name>Apache HttpClient Windows features</name>
=====================================
httpclient5/pom.xml
=====================================
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
- <version>5.1.1</version>
+ <version>5.1.2</version>
</parent>
<artifactId>httpclient5</artifactId>
<name>Apache HttpClient</name>
=====================================
httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java
=====================================
@@ -179,6 +179,7 @@ public ClassicHttpResponse execute(
if (Method.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request
+ ResponseEntityProxy.enhance(response, execRuntime);
return response;
}
final HttpEntity requestEntity = request.getEntity();
@@ -186,6 +187,7 @@ public ClassicHttpResponse execute(
if (LOG.isDebugEnabled()) {
LOG.debug("{} Cannot retry non-repeatable request", exchangeId);
}
+ ResponseEntityProxy.enhance(response, execRuntime);
return response;
}
if (needAuthentication(targetAuthExchange, proxyAuthExchange, route, request, response, context)) {
=====================================
httpclient5/src/main/resources/org/apache/hc/client5/version.properties
=====================================
@@ -16,7 +16,5 @@
# specific language governing permissions and limitations
# under the License.
#
-info.module = HttpClient
-info.release = ${pom.version}
-info.timestamp = ${mvn.timestamp}
-# timestamp requires Maven 2.1
+info.module = ${project.artifactId}
+info.release = ${project.version}
=====================================
pom.xml
=====================================
@@ -33,7 +33,7 @@
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-parent</artifactId>
<name>Apache HttpComponents Client Parent</name>
- <version>5.1.1</version>
+ <version>5.1.2</version>
<description>Apache HttpComponents Client is a library of components for building client side HTTP services</description>
<url>https://hc.apache.org/httpcomponents-client-5.0.x/${project.version}/</url>
<inceptionYear>1999</inceptionYear>
@@ -48,7 +48,7 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/httpcomponents-client.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/httpcomponents-client.git</developerConnection>
<url>https://github.com/apache/httpcomponents-client/tree/${project.scm.tag}</url>
- <tag>5.1.1</tag>
+ <tag>5.1.2</tag>
</scm>
<distributionManagement>
View it on GitLab: https://salsa.debian.org/java-team/httpcomponents-client5/-/commit/5240642d24e34ce249398b493dfa9a53be00d50e
--
View it on GitLab: https://salsa.debian.org/java-team/httpcomponents-client5/-/commit/5240642d24e34ce249398b493dfa9a53be00d50e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20211119/b663dbce/attachment.htm>
More information about the pkg-java-commits
mailing list