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:49 UTC

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

Branch: refs/heads/camel-2.12.x
Commit: 3b032653fb1772cc60aeff089cf8da6883b45699
Parents: 258e7d6
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:43:24 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/3b032653/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 3f24e09..e7d9184 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
@@ -417,7 +417,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?
@@ -426,6 +427,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);
             }