You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/02/28 03:20:07 UTC

[2/2] git commit: CAMEL-7256 Fixed the NPE of DefaultCxfRsBinding

CAMEL-7256 Fixed the NPE of DefaultCxfRsBinding


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

Branch: refs/heads/camel-2.11.x
Commit: 839b17e04ce387267fc6ffd167db7917a54c7f73
Parents: 94ce917
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Feb 28 10:03:01 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Feb 28 10:17:26 2014 +0800

----------------------------------------------------------------------
 .../camel/component/cxf/jaxrs/DefaultCxfRsBinding.java |  3 ++-
 .../camel/component/cxf/jaxrs/CxfRsConsumerTest.java   | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/839b17e0/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
index 7a3d3c8..6703af8 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
@@ -72,7 +72,8 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
     
     public Object populateCxfRsResponseFromExchange(Exchange camelExchange,
                                                     org.apache.cxf.message.Exchange cxfExchange) throws Exception {
-        if (camelExchange.isFailed()) {
+        // Need to check if the exchange has the exception
+        if (camelExchange.isFailed() && camelExchange.getException() != null) {
             throw camelExchange.getException();
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/839b17e0/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
index 51c10a0..52a7c09 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
@@ -91,6 +91,10 @@ public class CxfRsConsumerTest extends CamelTestSupport {
                                 if ("/customerservice/customers/456".equals(path)) {
                                     Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
                                     throw new WebApplicationException(r);
+                                } else if ("/customerservice/customers/234".equals(path)) {
+                                    Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
+                                    exchange.getOut().setBody(r);
+                                    exchange.getOut().setFault(true);
                                 } else {
                                     throw new RuntimeCamelException("Can't found the customer with uri " + path);
                                 }
@@ -153,6 +157,15 @@ public class CxfRsConsumerTest extends CamelTestSupport {
         } catch (FileNotFoundException exception) {
             // do nothing here
         }
+        
+        url = new URL("http://localhost:" + CXT + "/rest/customerservice/customers/234");
+        try {
+            url.openStream();
+            fail("Expect to get exception here");
+        } catch (FileNotFoundException exception) {
+            // do nothing here
+        }
+        
         url = new URL("http://localhost:" + CXT + "/rest/customerservice/customers/256");
         try {
             url.openStream();