Repository: camel Updated Branches: refs/heads/master 5f78c646c -> 336663c94
CAMEL-7213 NIOConverter need to call flip() when we put something into the buffer Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/336663c9 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/336663c9 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/336663c9 Branch: refs/heads/master Commit: 336663c940bca8d8e6326385217b8cf2ec2829de Parents: 5f78c64 Author: Willem Jiang <[email protected]> Authored: Mon Feb 17 14:29:46 2014 +0800 Committer: Willem Jiang <[email protected]> Committed: Mon Feb 17 14:29:46 2014 +0800 ---------------------------------------------------------------------- .../java/org/apache/camel/converter/NIOConverter.java | 5 +++++ .../java/org/apache/camel/converter/NIOConverterTest.java | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/336663c9/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 0bf08ac..41273b6 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 @@ -107,6 +107,7 @@ public final class NIOConverter { public static ByteBuffer toByteBuffer(Short value) { ByteBuffer buf = ByteBuffer.allocate(2); buf.putShort(value); + buf.flip(); return buf; } @@ -114,6 +115,7 @@ public final class NIOConverter { public static ByteBuffer toByteBuffer(Integer value) { ByteBuffer buf = ByteBuffer.allocate(4); buf.putInt(value); + buf.flip(); return buf; } @@ -121,6 +123,7 @@ public final class NIOConverter { public static ByteBuffer toByteBuffer(Long value) { ByteBuffer buf = ByteBuffer.allocate(8); buf.putLong(value); + buf.flip(); return buf; } @@ -128,6 +131,7 @@ public final class NIOConverter { public static ByteBuffer toByteBuffer(Float value) { ByteBuffer buf = ByteBuffer.allocate(4); buf.putFloat(value); + buf.flip(); return buf; } @@ -135,6 +139,7 @@ public final class NIOConverter { public static ByteBuffer toByteBuffer(Double value) { ByteBuffer buf = ByteBuffer.allocate(8); buf.putDouble(value); + buf.flip(); return buf; } http://git-wip-us.apache.org/repos/asf/camel/blob/336663c9/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java b/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java index cd56200..bcd423b 100644 --- a/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java +++ b/camel-core/src/test/java/org/apache/camel/converter/NIOConverterTest.java @@ -78,40 +78,30 @@ public class NIOConverterTest extends ContextTestSupport { public void testToByteBufferShort() { ByteBuffer bb = NIOConverter.toByteBuffer(Short.valueOf("2")); assertNotNull(bb); - - bb.position(0); assertEquals(2, bb.getShort()); } public void testToByteBufferInteger() { ByteBuffer bb = NIOConverter.toByteBuffer(Integer.valueOf("2")); assertNotNull(bb); - - bb.position(0); assertEquals(2, bb.getInt()); } public void testToByteBufferLong() { ByteBuffer bb = NIOConverter.toByteBuffer(Long.valueOf("2")); assertNotNull(bb); - - bb.position(0); assertEquals(2, bb.getLong()); } public void testToByteBufferDouble() { ByteBuffer bb = NIOConverter.toByteBuffer(Double.valueOf("2")); assertNotNull(bb); - - bb.position(0); assertEquals(2.0d, bb.getDouble()); } public void testToByteBufferFloat() { ByteBuffer bb = NIOConverter.toByteBuffer(Float.valueOf("2")); assertNotNull(bb); - - bb.position(0); assertEquals(2.0f, bb.getFloat()); }
