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/28 18:39:58 UTC

[1/2] cxf git commit: [CXF-6376] Rethrowing the escaped exception from JAX-RS out filter

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 <sb...@talend.com>
Authored: Tue Apr 28 17:38:41 2015 +0100
Committer: Sergey Beryozkin <sb...@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";


[2/2] cxf git commit: [CXF-6376] Adding a test resource

Posted by se...@apache.org.
[CXF-6376] Adding a test resource


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

Branch: refs/heads/2.7.x-fixes
Commit: c824bd84497d78e36868dd671430b14716b12b55
Parents: ba3a7da
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Tue Apr 28 17:39:29 2015 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Tue Apr 28 17:39:29 2015 +0100

----------------------------------------------------------------------
 .../systest/jaxrs/FaultyResponseHandler.java    | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c824bd84/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyResponseHandler.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyResponseHandler.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyResponseHandler.java
new file mode 100644
index 0000000..600b514
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FaultyResponseHandler.java
@@ -0,0 +1,40 @@
+/**
+ * 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 javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.ext.ResponseHandler;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.message.Message;
+
+public class FaultyResponseHandler implements ResponseHandler {
+    @Context
+    private MessageContext mc;
+    
+    public Response handleResponse(Message m, OperationResourceInfo ori, Response response) {
+        if (mc.getUriInfo().getPath().endsWith("/faultyResponseHandler")) {
+            throw new NullPointerException();
+        }
+        return null;
+    }
+
+}