You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/10/25 22:11:41 UTC

[httpcomponents-client] branch master updated (047c6c2 -> 65c6c25)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git.


 discard 047c6c2  [HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext) (#261)
     new 65c6c25  [HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext) (#261)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (047c6c2)
            \
             N -- N -- N   refs/heads/master (65c6c25)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[httpcomponents-client] 01/01: [HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext) (#261)

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 65c6c250708b409bc4eca8a16a9e5e8bd9870ffc
Author: Gary Gregory <ga...@users.noreply.github.com>
AuthorDate: Sun Oct 25 16:29:31 2020 -0400

    [HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext) (#261)
---
 .../sync/TestMinimalClientRequestExecution.java    | 25 ++++++++++++++++++----
 .../http/impl/classic/MinimalHttpClient.java       | 10 ++++-----
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
index 0092cf4..a42ae48 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
@@ -32,6 +32,7 @@ import java.util.Locale;
 import java.util.Set;
 
 import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
 import org.apache.hc.client5.http.impl.classic.HttpClients;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.core5.http.ClassicHttpRequest;
@@ -71,7 +72,7 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
     }
 
     @Test
-    public void testNonCompliantURI() throws Exception {
+    public void testNonCompliantURIWithContext() throws Exception {
         this.server.registerHandler("*", new SimpleService());
         this.httpclient = HttpClients.createMinimal();
         final HttpHost target = start();
@@ -79,9 +80,10 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
         final HttpClientContext context = HttpClientContext.create();
         for (int i = 0; i < 10; i++) {
             final HttpGet request = new HttpGet("/");
-            final ClassicHttpResponse response = this.httpclient.execute(target, request, context);
-            EntityUtils.consume(response.getEntity());
-            Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+            try (final CloseableHttpResponse response = this.httpclient.execute(target, request, context)) {
+                EntityUtils.consume(response.getEntity());
+                Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+            }
 
             final HttpRequest reqWrapper = context.getRequest();
             Assert.assertNotNull(reqWrapper);
@@ -98,4 +100,19 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
         }
     }
 
+    @Test
+    public void testNonCompliantURIWithoutContext() throws Exception {
+        this.server.registerHandler("*", new SimpleService());
+        this.httpclient = HttpClients.createMinimal();
+        final HttpHost target = start();
+
+        for (int i = 0; i < 10; i++) {
+            final HttpGet request = new HttpGet("/");
+            try (final CloseableHttpResponse response = this.httpclient.execute(target, request)) {
+                EntityUtils.consume(response.getEntity());
+                Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+            }
+        }
+    }
+
 }
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
index adf259e..2144099 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
@@ -142,14 +142,14 @@ public class MinimalHttpClient extends CloseableHttpClient {
                 execRuntime.connectEndpoint(clientContext);
             }
 
-            context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
-            context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
+            clientContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
+            clientContext.setAttribute(HttpClientContext.HTTP_ROUTE, route);
 
-            httpProcessor.process(request, request.getEntity(), context);
+            httpProcessor.process(request, request.getEntity(), clientContext);
             final ClassicHttpResponse response = execRuntime.execute(exchangeId, request, clientContext);
-            httpProcessor.process(response, response.getEntity(), context);
+            httpProcessor.process(response, response.getEntity(), clientContext);
 
-            if (reuseStrategy.keepAlive(request, response, context)) {
+            if (reuseStrategy.keepAlive(request, response, clientContext)) {
                 execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECOND);
             } else {
                 execRuntime.markConnectionNonReusable();