camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1003946 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Date Sun, 03 Oct 2010 11:07:29 GMT
Author: davsclaus
Date: Sun Oct  3 11:07:28 2010
New Revision: 1003946

URL: http://svn.apache.org/viewvc?rev=1003946&view=rev
Log:
CAMEL-3151: CxfProducer uses mandatory body to ensure input message exists. This avoids NPE
exceptions later on.

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=1003946&r1=1003945&r2=1003946&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Sun Oct  3 11:07:28 2010
@@ -30,6 +30,7 @@ import javax.xml.ws.handler.MessageConte
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
@@ -213,7 +214,7 @@ public class CxfProducer extends Default
         if (boi == null) {
             throw new RuntimeCamelException("Can't find the binding operation information
from camel exchange");
         }
-        if (!endpoint.isWrapped() && boi != null) {
+        if (!endpoint.isWrapped()) {
             if (boi.isUnwrappedCapable()) {
                 boi = boi.getUnwrappedOperation();
             }
@@ -253,7 +254,7 @@ public class CxfProducer extends Default
     /**
      * Get the parameters for the web service operation
      */
-    private Object[] getParams(CxfEndpoint endpoint, Exchange exchange) {
+    private Object[] getParams(CxfEndpoint endpoint, Exchange exchange) throws InvalidPayloadException
{
       
         Object[] params = null;
         if (endpoint.getDataFormat() == DataFormat.POJO) {
@@ -276,25 +277,22 @@ public class CxfProducer extends Default
                     params[0] = exchange.getIn().getBody();
                 }
             }
+            // make sure we have the right number of parameters
             checkParameterSize(endpoint, exchange, params);
-            
+
         } else if (endpoint.getDataFormat() == DataFormat.PAYLOAD) {
             params = new Object[1];
-            // TODO: maybe it should be mandatory body?
-            params[0] = exchange.getIn().getBody(CxfPayload.class);
+            params[0] = exchange.getIn().getMandatoryBody(CxfPayload.class);
         } else if (endpoint.getDataFormat() == DataFormat.MESSAGE) {
             params = new Object[1];
-            // TODO: maybe it should be mandatory body?
-            params[0] = exchange.getIn().getBody(InputStream.class);
+            params[0] = exchange.getIn().getMandatoryBody(InputStream.class);
         }
 
         if (LOG.isTraceEnabled()) {
-            if (params instanceof Object[]) {
+            if (params != null) {
                 for (int i = 0; i < params.length; i++) {
                     LOG.trace("params[" + i + "] = " + params[i]);
                 }
-            } else {
-                LOG.trace("params = " + params);
             }
         }
         



Mime
View raw message