Repository: cxf
Updated Branches:
  refs/heads/master 05cf29dc4 -> ac9b9b189


[CXF-6838] Correctly processing AsyncResponse resume with null


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ac9b9b18
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ac9b9b18
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ac9b9b18

Branch: refs/heads/master
Commit: ac9b9b1898bbe0cc911b34cc3d32664ac59fdc34
Parents: 05cf29d
Author: Sergey Beryozkin <[email protected]>
Authored: Tue Mar 22 17:58:12 2016 +0300
Committer: Sergey Beryozkin <[email protected]>
Committed: Tue Mar 22 17:58:12 2016 +0300

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java    |  6 +++++-
 .../systest/jaxrs/AbstractJAXRSContinuationsTest.java   | 12 ++++++++----
 .../apache/cxf/systest/jaxrs/BookContinuationStore.java |  7 +++++++
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ac9b9b18/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
----------------------------------------------------------------------
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
index 773faaf..7b3178d 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
@@ -272,7 +272,11 @@ public class AsyncResponseImpl implements AsyncResponse, 
ContinuationCallback {
     public synchronized Object getResponseObject() {
         Object obj = cont.getObject();
         if (!(obj instanceof Response) && !(obj instanceof Throwable)) {
-            obj = Response.ok().entity(obj).build();    
+            if (obj == null) {
+                obj = Response.noContent().build();
+            } else {
+                obj = Response.ok().entity(obj).build();
+            }
         }
         return obj;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ac9b9b18/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
index 9fc9d88..f2c152b 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
@@ -44,7 +44,6 @@ public abstract class AbstractJAXRSContinuationsTest extends 
AbstractBusClientSe
     @Test
     public void testDefaultTimeout() throws Exception {
         WebClient wc = WebClient.create("http://localhost:"; + getPort() + 
getBaseAddress() + "/books/defaulttimeout");
-        
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
         Response r = wc.get();
         assertEquals(503, r.getStatus());
     }
@@ -52,13 +51,20 @@ public abstract class AbstractJAXRSContinuationsTest 
extends AbstractBusClientSe
     @Test
     public void testImmediateResume() throws Exception {
         WebClient wc = WebClient.create("http://localhost:"; + getPort() + 
getBaseAddress() + "/books/resume");
-        
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
         wc.accept("text/plain");
         String str = wc.get(String.class);
         assertEquals("immediateResume", str);
     }
     
     @Test
+    public void testNoContent() throws Exception {
+        WebClient wc = WebClient.create("http://localhost:"; + getPort() + 
getBaseAddress() + "/books/nocontent");
+        wc.accept("text/plain");
+        Response r = wc.get(Response.class);
+        assertEquals(204, r.getStatus());
+    }
+    
+    @Test
     public void testUnmappedAfterTimeout() throws Exception {
         WebClient wc = WebClient.create("http://localhost:"; + getPort() + 
getBaseAddress() + "/books/suspend/unmapped");
         Response r = wc.get();
@@ -69,7 +75,6 @@ public abstract class AbstractJAXRSContinuationsTest extends 
AbstractBusClientSe
     public void testImmediateResumeSubresource() throws Exception {
         WebClient wc = WebClient.create("http://localhost:"; + getPort() 
                                         + getBaseAddress() + 
"/books/subresources/books/resume");
-        
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
         wc.accept("text/plain");
         String str = wc.get(String.class);
         assertEquals("immediateResume", str);
@@ -99,7 +104,6 @@ public abstract class AbstractJAXRSContinuationsTest extends 
AbstractBusClientSe
     
     protected void doTestTimeoutAndCancel(String baseAddress) throws Exception 
{
         WebClient wc = WebClient.create("http://localhost:"; + getPort() + 
baseAddress + "/books/cancel");
-        
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
         Response r = wc.get();
         assertEquals(503, r.getStatus());
         String retryAfter = r.getHeaderString(HttpHeaders.RETRY_AFTER);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ac9b9b18/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
index db37171..04c5c30 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
@@ -68,6 +68,13 @@ public class BookContinuationStore {
     }
     
     @GET
+    @Path("/books/nocontent")
+    @Produces("text/plain")
+    public void getBookNoContent(@Suspended AsyncResponse async) {
+        async.resume(null);
+    }
+    
+    @GET
     @Path("/books/cancel")
     public void getBookDescriptionWithCancel(@PathParam("id") String id, 
                                              @Suspended AsyncResponse async) {

Reply via email to