Actual number of bytes can be greater than the string length due to multibyte chars
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8af8af54 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8af8af54 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8af8af54 Branch: refs/heads/camel-2.19.x Commit: 8af8af5487bac55935a4ceec8e811a88cfa14eb7 Parents: 2ba7fb4 Author: Bhun Kho <bhun....@ictu.nl> Authored: Fri Jun 9 18:22:45 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Jun 9 19:12:39 2017 +0200 ---------------------------------------------------------------------- .../src/main/java/org/apache/camel/converter/NIOConverter.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8af8af54/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java b/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java index fbb573f..fabaa0d 100644 --- a/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java +++ b/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java @@ -84,7 +84,6 @@ public final class NIOConverter { @Converter public static ByteBuffer toByteBuffer(String value, Exchange exchange) { - ByteBuffer buf = ByteBuffer.allocate(value.length()); byte[] bytes = null; if (exchange != null) { String charsetName = exchange.getProperty(Exchange.CHARSET_NAME, String.class); @@ -99,9 +98,7 @@ public final class NIOConverter { if (bytes == null) { bytes = value.getBytes(); } - buf.put(bytes); - buf.flip(); - return buf; + return ByteBuffer.wrap(bytes); } @Converter