You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2020/10/26 01:34:10 UTC
[httpcomponents-client] branch 4.5.x updated: [HTTPCLIENT-2124]
NullPointerException in
org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost,
ClassicHttpRequest, HttpContext)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch 4.5.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/4.5.x by this push:
new 19d29f3 [HTTPCLIENT-2124] NullPointerException in org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext)
19d29f3 is described below
commit 19d29f3418b541fa070d192b0aacce2740c875f8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 25 21:34:00 2020 -0400
[HTTPCLIENT-2124] NullPointerException in
org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost,
ClassicHttpRequest, HttpContext)
Port test from master.
---
.../TestMinimalClientRequestExecution.java | 32 ++++++++++++++++++----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
index 203a29d..419cbc1 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
@@ -37,6 +37,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.StringEntity;
@@ -79,16 +80,19 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
final HttpClientContext context = HttpClientContext.create();
for (int i = 0; i < 10; i++) {
final HttpGet request = new HttpGet("/");
- final HttpResponse response = this.httpclient.execute(target, request, context);
- EntityUtils.consume(response.getEntity());
- Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-
+ final CloseableHttpResponse response = this.httpclient.execute(target, request, context);
+ try {
+ EntityUtils.consume(response.getEntity());
+ Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+ } finally {
+ response.close();
+ }
final HttpRequest reqWrapper = context.getRequest();
Assert.assertNotNull(reqWrapper);
final Header[] headers = reqWrapper.getAllHeaders();
final Set<String> headerSet = new HashSet<String>();
- for (final Header header: headers) {
+ for (final Header header : headers) {
headerSet.add(header.getName().toLowerCase(Locale.ROOT));
}
Assert.assertEquals(3, headerSet.size());
@@ -98,4 +102,22 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
}
}
+ @Test
+ public void testNonCompliantURIWithoutContext() throws Exception {
+ this.serverBootstrap.registerHandler("*", new SimpleService());
+ this.httpclient = HttpClients.createMinimal();
+ final HttpHost target = start();
+
+ for (int i = 0; i < 10; i++) {
+ final HttpGet request = new HttpGet("/");
+ final CloseableHttpResponse response = this.httpclient.execute(target, request);
+ try {
+ EntityUtils.consume(response.getEntity());
+ Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+ } finally {
+ response.close();
+ }
+ }
+ }
+
}