camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7935 Fixed the stackoverflow of JcloudsPayloadConverter.toPayload
Date Mon, 27 Oct 2014 08:32:20 GMT
CAMEL-7935 Fixed the stackoverflow of JcloudsPayloadConverter.toPayload


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

Branch: refs/heads/camel-2.13.x
Commit: ed622eb396be22dce3893795825a3fda2efa695d
Parents: 433b719
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Mon Oct 27 16:23:50 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Mon Oct 27 16:31:47 2014 +0800

----------------------------------------------------------------------
 .../component/jclouds/JcloudsPayloadConverter.java     | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ed622eb3/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsPayloadConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsPayloadConverter.java
b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsPayloadConverter.java
index 57a9269..27a6f59 100644
--- a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsPayloadConverter.java
+++ b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsPayloadConverter.java
@@ -22,17 +22,17 @@ import java.io.InputStream;
 import java.util.Date;
 
 import javax.xml.transform.stream.StreamSource;
+
 import com.google.common.io.ByteStreams;
 import com.google.common.io.InputSupplier;
+
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
 import org.apache.camel.FallbackConverter;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.converter.stream.StreamSourceCache;
 import org.apache.camel.spi.TypeConverterRegistry;
-import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.jclouds.io.Payload;
 import org.jclouds.io.payloads.ByteArrayPayload;
@@ -98,17 +98,14 @@ public final class JcloudsPayloadConverter {
 
     @Converter
     public static Payload toPayload(InputStream is, Exchange exchange) throws IOException
{
+        InputStreamPayload payload = new InputStreamPayload(is);
+        // only set the contentlength if possible
         if (is.markSupported()) {
-            InputStreamPayload payload = new InputStreamPayload(is);
             long contentLength = ByteStreams.length(payload);
             is.reset();
             payload.getContentMetadata().setContentLength(contentLength);
-            return payload;
-        } else {
-            CachedOutputStream cos = new CachedOutputStream(exchange);
-            IOHelper.copy(is, cos);
-            return toPayload(cos.getWrappedInputStream(), exchange);
         }
+        return payload;
     }
 
     @Converter


Mime
View raw message