You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/04/27 11:30:50 UTC

cxf git commit: [CXF-6373] Reporting Throwable to async completion callback if the unmapped exception gets thrown from the outbound chain, thanks to Iris Ding

Repository: cxf
Updated Branches:
  refs/heads/master 300ace67c -> 0f04f1510


[CXF-6373] Reporting Throwable to async completion callback if the unmapped exception gets thrown from the outbound chain, thanks to Iris Ding


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

Branch: refs/heads/master
Commit: 0f04f15104c101af194e4be913f3a66b89a52520
Parents: 300ace6
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Mon Apr 27 10:30:27 2015 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Mon Apr 27 10:30:27 2015 +0100

----------------------------------------------------------------------
 .../http/Servlet3ContinuationProvider.java      |  7 +++-
 .../jaxrs/AbstractJAXRSContinuationsTest.java   | 10 ++++++
 .../systest/jaxrs/BookContinuationFilter.java   | 38 ++++++++++++++++++++
 .../systest/jaxrs/BookContinuationStore.java    |  9 +++++
 .../resources/jaxrs_async/WEB-INF/beans.xml     |  5 ++-
 5 files changed, 67 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0f04f151/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
index 91b0624..d8f554c 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
@@ -177,7 +177,12 @@ public class Servlet3ContinuationProvider implements ContinuationProvider {
             inMessage.getExchange().getInMessage()
                 .remove(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE);
             if (callback != null) {
-                callback.onComplete();
+                final Exception ex = inMessage.getExchange().get(Exception.class);
+                if (ex == null) {
+                    callback.onComplete();
+                } else {
+                    callback.onError(ex);
+                }
             }
         }
         public void onError(AsyncEvent event) throws IOException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f04f151/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 b621a23..719967c 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
@@ -93,6 +93,16 @@ public abstract class AbstractJAXRSContinuationsTest extends AbstractBusClientSe
     }
     
     @Test
+    public void testGetBookUnmappedFromFilter() throws Exception {
+        WebClient wc = 
+            WebClient.create("http://localhost:" + getPort() + getBaseAddress() 
+                             + "/books/unmappedFromFilter");
+        wc.accept("text/plain");
+        Response r = wc.get();
+        assertEquals(500, r.getStatus());
+    }
+    
+    @Test
     public void testTimeoutAndCancel() throws Exception {
         doTestTimeoutAndCancel(getBaseAddress());
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f04f151/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationFilter.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationFilter.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationFilter.java
new file mode 100644
index 0000000..a4e0cbc
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationFilter.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jaxrs;
+
+import java.io.IOException;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+
+public class BookContinuationFilter implements ContainerResponseFilter {
+
+    @Override
+    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+        throws IOException {
+        if (requestContext.getUriInfo().getPath().endsWith("unmappedFromFilter")) {
+            throw new RuntimeException("Async exception from response filter");
+        }
+        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f04f151/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 0c800c8..24f3c0c 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
@@ -38,6 +38,7 @@ import javax.ws.rs.container.CompletionCallback;
 import javax.ws.rs.container.ConnectionCallback;
 import javax.ws.rs.container.Suspended;
 import javax.ws.rs.container.TimeoutHandler;
+import javax.ws.rs.core.Response;
 
 import org.apache.cxf.phase.PhaseInterceptorChain;
 
@@ -129,6 +130,14 @@ public class BookContinuationStore {
     }
     
     @GET
+    @Path("books/unmappedFromFilter")
+    @Produces("text/plain")
+    public void handleContinuationRequestUnmappedFromFilter(@Suspended AsyncResponse response) {
+        response.register(new CallbackImpl());
+        response.resume(Response.ok().build());
+    }
+    
+    @GET
     @Path("books/suspend/unmapped")
     @Produces("text/plain")
     public void handleNotMappedAfterSuspend(@Suspended AsyncResponse response) throws BookNotFoundFault {

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f04f151/systests/jaxrs/src/test/resources/jaxrs_async/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_async/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_async/WEB-INF/beans.xml
index 381cad8..8a37a14 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_async/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_async/WEB-INF/beans.xml
@@ -34,7 +34,10 @@
     <jaxrs:server id="bookservice" address="/async">
         <jaxrs:serviceBeans>
             <ref bean="serviceBean"/>
-        </jaxrs:serviceBeans>        
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <bean class="org.apache.cxf.systest.jaxrs.BookContinuationFilter"/>
+        </jaxrs:providers>        
         <jaxrs:properties>
             <entry key="disconnected.client.exception.class" value="org.eclipse.jetty.io.EofException"/>
         </jaxrs:properties>