hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1531408 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
Date Fri, 11 Oct 2013 20:05:37 GMT
Author: olegk
Date: Fri Oct 11 20:05:37 2013
New Revision: 1531408

URL: http://svn.apache.org/r1531408
Log:
HTTPCORE-355: HttpAsyncRequestExecutor fails when its handler is not ready to generate a request
Contributed by jd <j1234d2003 at yahoo.com>

Modified:
    httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1531408&r1=1531407&r2=1531408&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Oct 11 20:05:37 2013
@@ -1,6 +1,10 @@
 Changes since 4.3
 -------------------
 
+* [HTTPCORE-355] HttpAsyncRequestExecutor fails when its handler is not ready to generate
+  a request.
+  Contributed by jd <j1234d2003 at yahoo.com>
+
 * [HTTPCORE-354] BasicConnFactory don't use SocketConfig#isSoKeepAlive.
   Contributed by David Ignjic <ignjic at gmail.com>
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java?rev=1531408&r1=1531407&r2=1531408&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
Fri Oct 11 20:05:37 2013
@@ -143,6 +143,9 @@ public class HttpAsyncRequestExecutor im
         }
 
         final HttpRequest request = handler.generateRequest();
+        if (request == null) {
+            return;
+        }
         state.setRequest(request);
 
         conn.submitRequest(request);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java?rev=1531408&r1=1531407&r2=1531408&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
Fri Oct 11 20:05:37 2013
@@ -171,6 +171,21 @@ public class TestHttpAsyncRequestExecuto
     }
 
     @Test
+    public void testNullRequest() throws Exception {
+        final State state = new HttpAsyncRequestExecutor.State();
+        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
+        this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler);
+        Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(null);
+
+        this.protocolHandler.requestReady(this.conn);
+
+        Mockito.verify(this.exchangeHandler).generateRequest();
+        Assert.assertNull(state.getRequest());
+
+        Mockito.verify(this.conn, Mockito.never()).submitRequest(Mockito.<HttpRequest>any());
+    }
+
+    @Test
     public void testEntityEnclosingRequestWithoutExpectContinue() throws Exception {
         final State state = new HttpAsyncRequestExecutor.State();
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);



Mime
View raw message