You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/28 13:45:53 UTC

[10/11] git commit: CAMEL-5771 IOHelper.getCharsetName() should lookup CHARSET_NAME in headers if exchange property is not set

CAMEL-5771 IOHelper.getCharsetName() should lookup CHARSET_NAME in headers if exchange property is not set


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

Branch: refs/heads/camel-2.11.x
Commit: 8f8f2e9106e9498a2d9b4e5b101d1934c753f525
Parents: 45d5377
Author: Marco Zapletal <ma...@edistream.com>
Authored: Tue Sep 24 18:59:00 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 28 13:44:50 2013 +0200

----------------------------------------------------------------------
 camel-core/src/main/java/org/apache/camel/util/IOHelper.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8f8f2e91/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/IOHelper.java b/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
index 6799274..179d526 100644
--- a/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/IOHelper.java
@@ -390,7 +390,8 @@ public final class IOHelper {
     }
 
     /**
-     * Gets the charset name if set as property {@link Exchange#CHARSET_NAME}.
+     * Gets the charset name if set as property or header {@link Exchange#CHARSET_NAME}.
+     * Notice: The lookup from the property has priority over the header
      *
      * @param exchange  the exchange
      * @param useDefault should we fallback and use JVM default charset if no property existed?
@@ -399,6 +400,9 @@ public final class IOHelper {
     public static String getCharsetName(Exchange exchange, boolean useDefault) {
         if (exchange != null) {
             String charsetName = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
+            if (charsetName == null) {
+                charsetName = exchange.getIn().getHeader(Exchange.CHARSET_NAME, String.class);
+            }
             if (charsetName != null) {
                 return IOHelper.normalizeCharset(charsetName);
             }