mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +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:
parent
3a5abaf58a
commit
2d9bbec214
@ -31,6 +31,10 @@ class ArrayByteBuffer extends ByteBuffer {
|
||||
return b;
|
||||
}
|
||||
|
||||
public boolean hasArray() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte[] array() {
|
||||
return array;
|
||||
}
|
||||
@ -49,9 +53,10 @@ class ArrayByteBuffer extends ByteBuffer {
|
||||
}
|
||||
|
||||
public ByteBuffer put(ByteBuffer src) {
|
||||
checkPut(position, src.remaining());
|
||||
src.get(array, arrayOffset + position, src.remaining());
|
||||
position += src.remaining();
|
||||
int length = src.remaining();
|
||||
checkPut(position, length);
|
||||
src.get(array, arrayOffset + position, length);
|
||||
position += length;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -53,13 +53,15 @@ public abstract class ByteBuffer
|
||||
}
|
||||
|
||||
public ByteBuffer compact() {
|
||||
int remaining = remaining();
|
||||
|
||||
if (position != 0) {
|
||||
ByteBuffer b = slice();
|
||||
position = 0;
|
||||
put(b);
|
||||
}
|
||||
|
||||
position = remaining();
|
||||
position = remaining;
|
||||
limit(capacity());
|
||||
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user