You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/02/17 07:34:12 UTC
[3/3] git commit: CAMEL-7213 NIOConverter need to call flip() when we
put something into the buffer
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/d5811bab
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d5811bab
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d5811bab
Branch: refs/heads/camel-2.12.x
Commit: d5811bab9a6f48febd4ad7f9bcf7dc5d4373876c
Parents: 407cd12
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Feb 17 14:29:46 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Feb 17 14:33:45 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/d5811bab/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/d5811bab/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());
}