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 2022/06/06 16:50:02 UTC
[qpid-proton-j] branch main updated: PROTON-2554 Fix composite buffer read string APIs position updates
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-j.git
The following commit(s) were added to refs/heads/main by this push:
new c0927ce8 PROTON-2554 Fix composite buffer read string APIs position updates
c0927ce8 is described below
commit c0927ce8e2212d6f4b49cdbcc7d31d46c15f8c80
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Mon Jun 6 12:47:01 2022 -0400
PROTON-2554 Fix composite buffer read string APIs position updates
The API indicates the read string methods should advance the position to
the limit but the composite is not doing that.
---
.../org/apache/qpid/proton/codec/CompositeReadableBuffer.java | 3 +++
.../apache/qpid/proton/codec/CompositeReadableBufferTest.java | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
index cd6f6736..325f8a06 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
@@ -561,6 +561,9 @@ public class CompositeReadableBuffer implements ReadableBuffer {
decoded = readStringFromComponents(decoder);
}
+ // Ensure that all currently readable bytes are consumed.
+ position(limit);
+
return decoded.toString();
}
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/CompositeReadableBufferTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/CompositeReadableBufferTest.java
index a9d5c731..e4d4a915 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/CompositeReadableBufferTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/codec/CompositeReadableBufferTest.java
@@ -3283,6 +3283,7 @@ public class CompositeReadableBufferTest {
CompositeReadableBuffer buffer = new CompositeReadableBuffer();
assertEquals("", buffer.readString(StandardCharsets.UTF_8.newDecoder()));
+ assertFalse(buffer.hasRemaining());
}
@Test
@@ -3295,6 +3296,7 @@ public class CompositeReadableBufferTest {
buffer.append(encoded);
assertEquals(testString, buffer.readString(StandardCharsets.UTF_8.newDecoder()));
+ assertFalse(buffer.hasRemaining());
}
@Test
@@ -3309,6 +3311,7 @@ public class CompositeReadableBufferTest {
buffer.limit(1);
assertEquals("T", buffer.readString(StandardCharsets.UTF_8.newDecoder()));
+ assertFalse(buffer.hasRemaining());
}
@Test
@@ -3329,6 +3332,7 @@ public class CompositeReadableBufferTest {
String result = buffer.readString(StandardCharsets.UTF_8.newDecoder());
assertEquals(testString, result);
+ assertFalse(buffer.hasRemaining());
}
@Test
@@ -3350,6 +3354,7 @@ public class CompositeReadableBufferTest {
buffer.limit(1);
assertEquals("T", buffer.readString(StandardCharsets.UTF_8.newDecoder()));
+ assertFalse(buffer.hasRemaining());
}
@Test
@@ -3370,6 +3375,7 @@ public class CompositeReadableBufferTest {
String result = composite.readUTF8();
assertEquals("Failed to round trip String correctly: ", expected, result);
+ assertFalse(composite.hasRemaining());
}
@Test
@@ -3394,6 +3400,7 @@ public class CompositeReadableBufferTest {
String result = composite.readUTF8();
assertEquals("Failed to round trip String correctly: ", expected, result);
+ assertFalse(composite.hasRemaining());
}
@Test
@@ -3420,6 +3427,7 @@ public class CompositeReadableBufferTest {
String result = composite.readUTF8();
assertEquals("Failed to round trip String correctly: ", expected, result);
+ assertFalse(composite.hasRemaining());
}
@Test
@@ -3441,6 +3449,7 @@ public class CompositeReadableBufferTest {
String result = slicedComposite.readUTF8();
assertEquals("Failed to round trip String correctly: ", expected, result);
+ assertFalse(slicedComposite.hasRemaining());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org