You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2018/08/14 18:33:51 UTC
qpid-jms git commit: QPIDJMS-408 Implement the string write method of
WritableBuffer
Repository: qpid-jms
Updated Branches:
refs/heads/master e72a72c9d -> c5c90534c
QPIDJMS-408 Implement the string write method of WritableBuffer
Implement the put(String) method for the WritableBuffer interface
introduced in proton-j 0.29.0 which allows us to use the Netty ByteBuf
string encoding to perform string encodes faster than the default
version in proton-j
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/c5c90534
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/c5c90534
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/c5c90534
Branch: refs/heads/master
Commit: c5c90534c2a761cd32e2462b942d00b420a7358d
Parents: e72a72c
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Aug 14 14:33:33 2018 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Aug 14 14:33:33 2018 -0400
----------------------------------------------------------------------
.../jms/provider/amqp/message/AmqpWritableBuffer.java | 6 ++++++
.../provider/amqp/message/AmqpWritableBufferTest.java | 14 ++++++++++++++
2 files changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c5c90534/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBuffer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBuffer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBuffer.java
index 77bb253..2f52bff 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBuffer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBuffer.java
@@ -17,6 +17,7 @@
package org.apache.qpid.jms.provider.amqp.message;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import org.apache.qpid.proton.codec.ReadableBuffer;
import org.apache.qpid.proton.codec.WritableBuffer;
@@ -90,6 +91,11 @@ public class AmqpWritableBuffer implements WritableBuffer {
}
@Override
+ public void put(String value) {
+ nettyBuffer.writeCharSequence(value, StandardCharsets.UTF_8);
+ }
+
+ @Override
public boolean hasRemaining() {
return nettyBuffer.writerIndex() < nettyBuffer.maxCapacity();
}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c5c90534/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBufferTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBufferTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBufferTest.java
index 981556d..30a17e3 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBufferTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpWritableBufferTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import org.apache.qpid.proton.codec.ReadableBuffer;
import org.junit.Test;
@@ -120,6 +121,19 @@ public class AmqpWritableBufferTest {
}
@Test
+ public void testPutString() {
+ String ascii = new String("ASCII");
+
+ ByteBuf buffer = Unpooled.buffer(1024);
+ AmqpWritableBuffer writable = new AmqpWritableBuffer(buffer);
+
+ assertEquals(0, writable.position());
+ writable.put(ascii);
+ assertEquals(ascii.length(), writable.position());
+ assertEquals(ascii, writable.getBuffer().toString(StandardCharsets.UTF_8));
+ }
+
+ @Test
public void testPutReadableBuffer() {
doPutReadableBufferTestImpl(true);
doPutReadableBufferTestImpl(false);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org