You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/10/27 09:28:47 UTC

git commit: CAMEL-7935 Fixed the stackoverflow of JcloudsPayloadConverter.toPayload

Repository: camel
Updated Branches:
  refs/heads/master b5f1da228 -> 5bd6ee781


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

Branch: refs/heads/master
Commit: 5bd6ee781bb9b1fb4beb806e2152603f134b8575
Parents: b5f1da2
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Oct 27 16:23:50 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Oct 27 16:23:50 2014 +0800

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


http://git-wip-us.apache.org/repos/asf/camel/blob/5bd6ee78/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