CAMEL-6471: CXF in PAYLOAD mode should not output body/headers in the toString 
as that may force loading into memory. Also log if payload mode is allowing 
streaming or not, as thats not easy to see how is configured.


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

Branch: refs/heads/master
Commit: efbb85961a2ad932d15164a01e2823ce1fe0ef54
Parents: b5c5c26
Author: Claus Ibsen <[email protected]>
Authored: Thu Jun 20 13:48:16 2013 +0200
Committer: Claus Ibsen <[email protected]>
Committed: Thu Jun 20 13:48:16 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfPayload.java  | 29 ++------------------
 .../cxf/feature/PayLoadDataFormatFeature.java   |  4 +++
 2 files changed, 6 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/efbb8596/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
index f40efcd..2fad481 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
@@ -130,34 +130,9 @@ public class CxfPayload<T> {
         return headers;
     }
     
-    /**
-     * Returns the contents as a String
-     * Important notes:
-     *   1) This requires the message to be fully loaded breaking the streaming
-     *   2) For large messages, the result can be a VERY large String and 
require
-     *   large amounts of memory.
-     */
     public String toString() {
-        StringBuilder buf = new StringBuilder();
-        buf.append(getClass().getName());
-        buf.append(" headers: " + headers);
-        // go through the list of element and turn it into String
-        if (body == null) {
-            buf.append("body: " + body);
-        } else {
-            buf.append("body: [ ");
-            for (Element src : getBody()) {
-                String elementString;
-                try {
-                    elementString = StaxUtils.toString(src);
-                } catch (XMLStreamException e) {
-                    elementString = src.toString();
-                }
-                buf.append("[" + elementString + "]");
-            }
-            buf.append("]");
-        }
-        return buf.toString();
+        // do not load or print the payload body etc as we do not want to load 
that into memory etc
+        return super.toString();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/efbb8596/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
index 4642358..dae5b86 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
@@ -85,6 +85,8 @@ public class PayLoadDataFormatFeature extends 
AbstractDataFormatFeature {
                           SoapHeaderInterceptor.class);
         client.getEndpoint().getBinding().getInInterceptors().add(new 
ConfigureDocLitWrapperInterceptor(true));
         resetPartTypes(client.getEndpoint().getBinding());
+
+        LOG.info("Initialized CXF Client: {} in Payload mode with allow 
streaming: {}", client, allowStreaming);
     }
 
 
@@ -103,6 +105,8 @@ public class PayLoadDataFormatFeature extends 
AbstractDataFormatFeature {
         
removeInterceptor(server.getEndpoint().getBinding().getInInterceptors(), 
                           SoapHeaderInterceptor.class);
         resetPartTypes(server.getEndpoint().getBinding());
+
+        LOG.info("Initialized CXF Server: {} in Payload mode with allow 
streaming: {}", server, allowStreaming);
     }
 
     @Override

Reply via email to