Repository: camel
Updated Branches:
  refs/heads/master 87105eee5 -> 0ccf76890


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/0ccf7689
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0ccf7689
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0ccf7689

Branch: refs/heads/master
Commit: 0ccf7689046ab3f5e335582d7756f728e7bdf7d2
Parents: 87105ee
Author: Willem Jiang <[email protected]>
Authored: Fri Feb 28 10:03:01 2014 +0800
Committer: Willem Jiang <[email protected]>
Committed: Fri Feb 28 10:03:24 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/0ccf7689/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/0ccf7689/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 3ad6170..2dc110a 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();

Reply via email to