mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
fix a couple of ByteBuffer regressions
The compact() and put(ByteBuffer) methods regressed as of the recent refactoring to support direct byte buffers.
This commit is contained in:
@ -31,6 +31,10 @@ class ArrayByteBuffer extends ByteBuffer {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasArray() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] array() {
|
public byte[] array() {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
@ -49,9 +53,10 @@ class ArrayByteBuffer extends ByteBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ByteBuffer put(ByteBuffer src) {
|
public ByteBuffer put(ByteBuffer src) {
|
||||||
checkPut(position, src.remaining());
|
int length = src.remaining();
|
||||||
src.get(array, arrayOffset + position, src.remaining());
|
checkPut(position, length);
|
||||||
position += src.remaining();
|
src.get(array, arrayOffset + position, length);
|
||||||
|
position += length;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,13 +53,15 @@ public abstract class ByteBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ByteBuffer compact() {
|
public ByteBuffer compact() {
|
||||||
|
int remaining = remaining();
|
||||||
|
|
||||||
if (position != 0) {
|
if (position != 0) {
|
||||||
ByteBuffer b = slice();
|
ByteBuffer b = slice();
|
||||||
position = 0;
|
position = 0;
|
||||||
put(b);
|
put(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
position = remaining();
|
position = remaining;
|
||||||
limit(capacity());
|
limit(capacity());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
Reference in New Issue
Block a user