cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6838] Correctly processing AsyncResponse resume with null
Date Tue, 22 Mar 2016 14:59:32 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 9787e41fd -> e4de49b41


[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/e4de49b4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e4de49b4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e4de49b4

Branch: refs/heads/3.1.x-fixes
Commit: e4de49b410966bf70326ec7d118a6d564ae3aa1e
Parents: 9787e41
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Mar 22 17:58:12 2016 +0300
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Mar 22 17:59:15 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/e4de49b4/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/e4de49b4/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/e4de49b4/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) {


Mime
View raw message