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 2010/07/02 12:07:51 UTC

svn commit: r959933 - in /httpcomponents/httpcore/branches/4.0.x: ./ RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java

Author: olegk
Date: Fri Jul  2 10:07:51 2010
New Revision: 959933

URL: http://svn.apache.org/viewvc?rev=959933&view=rev
Log:
HTTPCORE-228: Fixed NPE in AsyncNHttpServiceHandler caused by entity enclosing requests if no matching request handler can be found

Modified:
    httpcomponents/httpcore/branches/4.0.x/   (props changed)
    httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java

Propchange: httpcomponents/httpcore/branches/4.0.x/
------------------------------------------------------------------------------
    svn:mergeinfo = /httpcomponents/httpcore/trunk:959930-959931

Modified: httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt?rev=959933&r1=959932&r2=959933&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt Fri Jul  2 10:07:51 2010
@@ -1,5 +1,9 @@
 Changes since 4.0.1
 
+* [HTTPCORE-228] Fixed NPE in AsyncNHttpServiceHandler caused by entity enclosing requests
+  if no matching request handler can be found.  
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-222] Fixed OSGi Import-Package
   Contributed by Willem Jiang <willem.jiang at gmail.com>
 

Modified: httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java?rev=959933&r1=959932&r2=959933&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java (original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java Fri Jul  2 10:07:51 2010
@@ -177,7 +177,8 @@ public class AsyncNHttpServiceHandler ex
         try {
 
             if (request instanceof HttpEntityEnclosingRequest) {
-                if (((HttpEntityEnclosingRequest) request).expectContinue()) {
+                HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) request;
+                if (entityRequest.expectContinue()) {
                     response = this.responseFactory.newHttpResponse(
                             ver, HttpStatus.SC_CONTINUE, context);
                     response.setParams(
@@ -207,20 +208,19 @@ public class AsyncNHttpServiceHandler ex
                     }
                 }
                 // Request content is expected.
-                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+                ConsumingNHttpEntity consumingEntity = null;
 
                 // Lookup request handler for this request
                 if (requestHandler != null) {
-                    ConsumingNHttpEntity consumingEntity = requestHandler.entityRequest(
-                            (HttpEntityEnclosingRequest) request, context);
-                    if (consumingEntity == null) {
-                        consumingEntity = new ConsumingNHttpEntityTemplate(
-                                entity,
-                                new SkipContentListener(this.allocator));
-                    }
-                    ((HttpEntityEnclosingRequest) request).setEntity(consumingEntity);
-                    connState.setConsumingEntity(consumingEntity);
+                    consumingEntity = requestHandler.entityRequest(entityRequest, context);
+                }
+                if (consumingEntity == null) {
+                    consumingEntity = new ConsumingNHttpEntityTemplate(
+                            entityRequest.getEntity(),
+                            new SkipContentListener(this.allocator));
                 }
+                entityRequest.setEntity(consumingEntity);
+                connState.setConsumingEntity(consumingEntity);
 
             } else {
                 // No request content is expected.