Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 99160187DD for ; Tue, 22 Mar 2016 14:58:27 +0000 (UTC) Received: (qmail 80781 invoked by uid 500); 22 Mar 2016 14:58:27 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 80693 invoked by uid 500); 22 Mar 2016 14:58:27 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 80682 invoked by uid 99); 22 Mar 2016 14:58:27 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Mar 2016 14:58:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F9EEDFB77; Tue, 22 Mar 2016 14:58:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: <9071f53964204c579183fc41783857cb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-6838] Correctly processing AsyncResponse resume with null Date: Tue, 22 Mar 2016 14:58:27 +0000 (UTC) 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 Authored: Tue Mar 22 17:58:12 2016 +0300 Committer: Sergey Beryozkin 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) {