Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion camel-core/src/main/java/org/apache/camel/util/IOHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ public static String getCharsetName(Exchange exchange) {
}

/**
* 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?
Expand All @@ -426,6 +427,9 @@ public static String getCharsetName(Exchange exchange) {
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);
}
Expand Down