camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject camel git commit: [CAMEL-10176]camel-cxf RawMessageContentRedirectInterceptor should be able to handle the case that OutputStream is null for an outgoing message
Date Mon, 25 Jul 2016 06:35:23 GMT
Repository: camel
Updated Branches:
  refs/heads/master c8a458a79 -> 37644948f


[CAMEL-10176]camel-cxf RawMessageContentRedirectInterceptor should be able to handle the case
that OutputStream is null for an outgoing message


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

Branch: refs/heads/master
Commit: 37644948fb546604b8f1e3f1ce5b308c77ca9926
Parents: c8a458a
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Mon Jul 25 14:35:04 2016 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Mon Jul 25 14:35:04 2016 +0800

----------------------------------------------------------------------
 .../RawMessageContentRedirectInterceptor.java      | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/37644948/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
index 86a6dc4..bd49955 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
@@ -17,13 +17,16 @@
 package org.apache.camel.component.cxf.interceptors;
 
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.Writer;
 import java.util.List;
 
 import org.apache.camel.StreamCache;
 import org.apache.camel.util.IOHelper;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -49,16 +52,20 @@ public class RawMessageContentRedirectInterceptor extends AbstractPhaseIntercept
         if (null != params) {
             InputStream is = (InputStream)params.get(0);
             OutputStream os = message.getContent(OutputStream.class);
-            if (os == null) {
+            Writer writer = message.getContent(Writer.class);
+            if (os == null && writer == null) {
                 //InOny
                 return;
             }
-
             try {
-                if (is instanceof StreamCache) {
-                    ((StreamCache)is).writeTo(os);
+                if (os == null && writer != null) {
+                    IOUtils.copyAndCloseInput(new InputStreamReader(is), writer);
                 } else {
-                    IOUtils.copy(is, os);
+                    if (is instanceof StreamCache) {
+                        ((StreamCache)is).writeTo(os);
+                    } else {
+                        IOUtils.copy(is, os);
+                    }
                 }
             } catch (Exception e) {
                 throw new Fault(e);


Mime
View raw message