camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/5] camel git commit: CAMEL-8113: Optimize type converter registry.
Date Thu, 18 Dec 2014 20:28:11 GMT
CAMEL-8113: Optimize type converter registry.


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

Branch: refs/heads/master
Commit: a707e51ca5e29ed4396aa2e7bfc69fa604bc7614
Parents: 5cfa913
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 18 16:54:33 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 18 21:27:57 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/component/file/FileOperations.java  | 2 +-
 .../src/main/java/org/apache/camel/util/MessageHelper.java    | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a707e51c/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
index 7851cfc..5bf82bb 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
@@ -259,7 +259,7 @@ public class FileOperations implements GenericFileOperations<File>
{
 
             if (charset != null) {
                 // charset configured so we must use a reader so we can write with encoding
-                Reader in = exchange.getIn().getBody(Reader.class);
+                Reader in = exchange.getContext().getTypeConverter().tryConvertTo(Reader.class,
exchange, exchange.getIn().getBody());
                 if (in == null) {
                     // okay no direct reader conversion, so use an input stream (which a
lot can be converted as)
                     InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/a707e51c/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
index 879fcbf..f0cae78 100644
--- a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
@@ -67,6 +67,13 @@ public final class MessageHelper {
             return null;
         }
 
+        // optimize if the body is a String type already
+        Object body = message.getBody();
+        if (body instanceof String) {
+            return (String) body;
+        }
+
+        // we need to favor using stream cache so the body can be re-read later
         StreamCache newBody = message.getBody(StreamCache.class);
         if (newBody != null) {
             message.setBody(newBody);


Mime
View raw message