Github user tabish121 commented on a diff in the pull request:
https://github.com/apache/qpid-proton-j/pull/20#discussion_r234811453
--- Diff:
proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
---
@@ -834,22 +834,39 @@ public boolean equals(Object other) {
return false;
}
- ReadableBuffer buffer = (ReadableBuffer)other;
- if (this.remaining() != buffer.remaining()) {
+ ReadableBuffer buffer = (ReadableBuffer) other;
+ final int remaining = remaining();
+ if (remaining != buffer.remaining()) {
return false;
}
+ if (hasArray()) {
+ return equals(currentArray, position, remaining, buffer);
--- End diff --
For the single array case, when you have a slice that you've created from a
CRB that is not starting from zero then the current offset will be non-zero but
position would be so the equals check should be starting at current offset and
moving forward however many elements the limit allows for.
The position and the offset work together to control where zero is in the
buffer, you can do a get for some index in the buffer and the position controls
how far back you can rewind the offset until you've hit "zero" which might not
be zero in the array.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]