camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-11379: Optimise - core type converters to be invoked faster
Date Sun, 25 Jun 2017 18:41:25 GMT
Repository: camel
Updated Branches:
  refs/heads/master 5c554b085 -> 9c094e4dc


CAMEL-11379: Optimise - core type converters to be invoked faster


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

Branch: refs/heads/master
Commit: 9c094e4dcbc4ebd8a5fd02d6a4879cd3a414eaed
Parents: 5c554b0
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jun 25 19:26:17 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jun 25 19:26:17 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/converter/IOConverterOptimised.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9c094e4d/camel-core/src/main/java/org/apache/camel/converter/IOConverterOptimised.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/converter/IOConverterOptimised.java
b/camel-core/src/main/java/org/apache/camel/converter/IOConverterOptimised.java
index 6ae8779..cddfda4 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/IOConverterOptimised.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/IOConverterOptimised.java
@@ -30,6 +30,7 @@ import java.net.URL;
 import java.util.Properties;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.StreamCache;
 
 /**
  * Optimised {@link IOConverter}
@@ -43,6 +44,12 @@ public final class IOConverterOptimised {
     public static Object convertTo(final Class<?> type, final Exchange exchange, final
Object value) throws Exception {
         Class fromType = value.getClass();
 
+        // if the value is StreamCache then ensure its readable before doing conversions
+        // by resetting it (this is also what StreamCachingAdvice does)
+        if (value instanceof StreamCache) {
+            ((StreamCache) value).reset();
+        }
+
         if (type == InputStream.class) {
             if (fromType == String.class) {
                 return IOConverter.toInputStream((String) value, exchange);
@@ -134,6 +141,11 @@ public final class IOConverterOptimised {
 
         if (type == ObjectInput.class) {
             if (fromType == InputStream.class || fromType == BufferedInputStream.class) {
+                // if the value is both an InputStream and StreamCache then ensure its readable
+                // before doing conversions by resetting it (this is also what StreamCachingAdvice
does)
+                if (value instanceof StreamCache) {
+                    ((StreamCache) value).reset();
+                }
                 return IOConverter.toObjectInput((InputStream) value, exchange);
             }
             return null;


Mime
View raw message