cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-6376] Rethrowing the escaped exception from JAX-RS out filter
Date Tue, 28 Apr 2015 16:39:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes a8352df64 -> c824bd844


[CXF-6376] Rethrowing the escaped exception from JAX-RS out filter


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

Branch: refs/heads/2.7.x-fixes
Commit: ba3a7da4c9d23c4c914a9e17d0abbc97ae7da4ca
Parents: a8352df
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Apr 28 17:38:41 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Apr 28 17:38:41 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java   | 4 +++-
 .../test/java/org/apache/cxf/systest/jaxrs/BookServer.java  | 1 +
 .../test/java/org/apache/cxf/systest/jaxrs/BookStore.java   | 6 ++++++
 .../apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java | 9 ++++++++-
 4 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ba3a7da4/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
index 0a9968c..60257cf 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
@@ -49,6 +49,7 @@ import javax.xml.stream.events.XMLEvent;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.AsyncResponseImpl;
@@ -85,7 +86,8 @@ public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor
{
         try {
             processResponse(providerFactory, message);
         } catch (Exception ex) {
-            message.put("jaxrs.out.fault", Boolean.TRUE);    
+            message.put("jaxrs.out.fault", Boolean.TRUE);
+            throw new Fault(ex);
         } finally {
             Object rootInstance = message.getExchange().remove(JAXRSUtils.ROOT_INSTANCE);
             Object rootProvider = message.getExchange().remove(JAXRSUtils.ROOT_PROVIDER);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ba3a7da4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
index 3c07227..52a3d9b 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
@@ -78,6 +78,7 @@ public class BookServer extends AbstractBusTestServerBase {
         providers.add(new FormatResponseHandler());
         providers.add(new GenericHandlerWriter());
         providers.add(new FaultyRequestHandler());
+        providers.add(new FaultyResponseHandler());
         providers.add(new SearchContextProvider());
         providers.add(new QueryContextProvider());
         sf.setProviders(providers);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ba3a7da4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index e794383..792688e 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -144,6 +144,12 @@ public class BookStore {
     }
 
     @GET
+    @Path("faultyResponseHandler")
+    public Book testFaultyResponseHandler() {
+        return new Book("root", 124L);
+    }
+    
+    @GET
     @Path("/")
     public Book getBookRoot() {
         return new Book("root", 124L);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ba3a7da4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index 596e904..25ea94c 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -92,7 +92,14 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
                    launchServer(BookServer.class, true));
         createStaticBus();
     }
-    
+    @Test
+    public void testExceptionFromFaultyResponseHandler() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/faultyResponseHandler";
+        WebClient wc = WebClient.create(address);
+        WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true);
+        Response r = wc.get();
+        assertEquals(500, r.getStatus());
+    }
     @Test
     public void testGetBookRoot() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/;JSESSIONID=xxx";


Mime
View raw message