commit
f3c86e3fbc
@ -28,8 +28,8 @@ public interface BufferAllocator extends AutoCloseable {
|
||||
* Check that the given {@code size} argument is a valid buffer size, or throw an {@link IllegalArgumentException}.
|
||||
*
|
||||
* @param size The size to check.
|
||||
* @throws IllegalArgumentException if the size is not possitive, or if the size is too big (over ~2 GB) for a
|
||||
* buffer to accomodate.
|
||||
* @throws IllegalArgumentException if the size is not positive, or if the size is too big (over ~2 GB) for a
|
||||
* buffer to accommodate.
|
||||
*/
|
||||
static void checkSize(long size) {
|
||||
if (size < 1) {
|
||||
|
@ -145,7 +145,7 @@ public final class CompositeBuffer extends ResourceSupport<Buffer, CompositeBuff
|
||||
* @throws IllegalArgumentException if the given buffers have an inconsistent
|
||||
* {@linkplain Buffer#order() byte order}.
|
||||
* @throws IllegalStateException if one of the sends have already been received. The remaining buffers and sends
|
||||
* will be closed and descarded, respectively.
|
||||
* will be closed and discarded, respectively.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static CompositeBuffer compose(BufferAllocator allocator, Send<Buffer>... sends) {
|
||||
@ -321,7 +321,7 @@ public final class CompositeBuffer extends ResourceSupport<Buffer, CompositeBuff
|
||||
if (cap > MAX_CAPACITY) {
|
||||
throw new IllegalArgumentException(
|
||||
"Combined size of the constituent buffers is too big. " +
|
||||
"The maximum buffer capacity is " + MAX_CAPACITY + " (Interger.MAX_VALUE - 8), " +
|
||||
"The maximum buffer capacity is " + MAX_CAPACITY + " (Integer.MAX_VALUE - 8), " +
|
||||
"but the sum of the constituent buffer capacities was " + cap + '.');
|
||||
}
|
||||
capacity = (int) cap;
|
||||
|
@ -52,7 +52,7 @@ class NioBuffer extends ResourceSupport<Buffer, NioBuffer> implements Buffer, Re
|
||||
private boolean constBuffer;
|
||||
|
||||
NioBuffer(ByteBuffer base, ByteBuffer memory, AllocatorControl control, Drop<NioBuffer> drop) {
|
||||
super(new MakeInaccisbleOnDrop(ArcDrop.wrap(drop)));
|
||||
super(new MakeInaccessibleOnDrop(ArcDrop.wrap(drop)));
|
||||
this.base = base;
|
||||
rmem = memory;
|
||||
wmem = memory;
|
||||
@ -63,7 +63,7 @@ class NioBuffer extends ResourceSupport<Buffer, NioBuffer> implements Buffer, Re
|
||||
* Constructor for {@linkplain BufferAllocator#constBufferSupplier(byte[]) const buffers}.
|
||||
*/
|
||||
NioBuffer(NioBuffer parent) {
|
||||
super(new MakeInaccisbleOnDrop(new ArcDrop<>(ArcDrop.acquire(parent.unsafeGetDrop()))));
|
||||
super(new MakeInaccessibleOnDrop(new ArcDrop<>(ArcDrop.acquire(parent.unsafeGetDrop()))));
|
||||
control = parent.control;
|
||||
base = parent.base;
|
||||
rmem = bbslice(parent.rmem, 0, parent.rmem.capacity()); // Need to slice to get independent byte orders.
|
||||
@ -75,10 +75,10 @@ class NioBuffer extends ResourceSupport<Buffer, NioBuffer> implements Buffer, Re
|
||||
constBuffer = true;
|
||||
}
|
||||
|
||||
private static final class MakeInaccisbleOnDrop implements Drop<NioBuffer> {
|
||||
private static final class MakeInaccessibleOnDrop implements Drop<NioBuffer> {
|
||||
final Drop<NioBuffer> delegate;
|
||||
|
||||
private MakeInaccisbleOnDrop(Drop<NioBuffer> delegate) {
|
||||
private MakeInaccessibleOnDrop(Drop<NioBuffer> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@ -98,19 +98,19 @@ class NioBuffer extends ResourceSupport<Buffer, NioBuffer> implements Buffer, Re
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MemSegDrop(" + delegate + ')';
|
||||
return "MakeInaccessibleOnDrop(" + delegate + ')';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drop<NioBuffer> unsafeGetDrop() {
|
||||
MakeInaccisbleOnDrop drop = (MakeInaccisbleOnDrop) super.unsafeGetDrop();
|
||||
MakeInaccessibleOnDrop drop = (MakeInaccessibleOnDrop) super.unsafeGetDrop();
|
||||
return drop.delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unsafeSetDrop(Drop<NioBuffer> replacement) {
|
||||
super.unsafeSetDrop(new MakeInaccisbleOnDrop(replacement));
|
||||
super.unsafeSetDrop(new MakeInaccessibleOnDrop(replacement));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -165,7 +165,7 @@ public abstract class LifecycleTracer {
|
||||
|
||||
public <E extends Throwable> void attach(E throwable, long timestamp) {
|
||||
Trace recv = received;
|
||||
String message = sent && recv == null? name + " (sent but not received)" : name;
|
||||
String message = sent && recv == null ? name + " (sent but not received)" : name;
|
||||
message += " (current acquires = " + acquires + ") T" + (this.timestamp - timestamp) / 1000 + "µs.";
|
||||
Traceback exception = new Traceback(message);
|
||||
StackTraceElement[] stackTrace = new StackTraceElement[frames.length];
|
||||
|
@ -59,7 +59,7 @@ class UnsafeBuffer extends ResourceSupport<Buffer, UnsafeBuffer> implements Buff
|
||||
|
||||
UnsafeBuffer(UnsafeMemory memory, long offset, int size, AllocatorControl allocatorControl,
|
||||
Drop<UnsafeBuffer> drop) {
|
||||
super(new MakeInaccisbleOnDrop(ArcDrop.wrap(drop)));
|
||||
super(new MakeInaccessibleOnDrop(ArcDrop.wrap(drop)));
|
||||
this.memory = memory;
|
||||
base = memory.base;
|
||||
baseOffset = offset;
|
||||
@ -71,7 +71,7 @@ class UnsafeBuffer extends ResourceSupport<Buffer, UnsafeBuffer> implements Buff
|
||||
}
|
||||
|
||||
UnsafeBuffer(UnsafeBuffer parent) {
|
||||
super(new MakeInaccisbleOnDrop(new ArcDrop<>(ArcDrop.acquire(parent.unsafeGetDrop()))));
|
||||
super(new MakeInaccessibleOnDrop(new ArcDrop<>(ArcDrop.acquire(parent.unsafeGetDrop()))));
|
||||
control = parent.control;
|
||||
memory = parent.memory;
|
||||
base = parent.base;
|
||||
@ -1254,19 +1254,19 @@ class UnsafeBuffer extends ResourceSupport<Buffer, UnsafeBuffer> implements Buff
|
||||
|
||||
@Override
|
||||
protected Drop<UnsafeBuffer> unsafeGetDrop() {
|
||||
MakeInaccisbleOnDrop drop = (MakeInaccisbleOnDrop) super.unsafeGetDrop();
|
||||
MakeInaccessibleOnDrop drop = (MakeInaccessibleOnDrop) super.unsafeGetDrop();
|
||||
return drop.delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unsafeSetDrop(Drop<UnsafeBuffer> replacement) {
|
||||
super.unsafeSetDrop(new MakeInaccisbleOnDrop(replacement));
|
||||
super.unsafeSetDrop(new MakeInaccessibleOnDrop(replacement));
|
||||
}
|
||||
|
||||
private static final class MakeInaccisbleOnDrop implements Drop<UnsafeBuffer> {
|
||||
private static final class MakeInaccessibleOnDrop implements Drop<UnsafeBuffer> {
|
||||
final Drop<UnsafeBuffer> delegate;
|
||||
|
||||
private MakeInaccisbleOnDrop(Drop<UnsafeBuffer> delegate) {
|
||||
private MakeInaccessibleOnDrop(Drop<UnsafeBuffer> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@ -1286,7 +1286,7 @@ class UnsafeBuffer extends ResourceSupport<Buffer, UnsafeBuffer> implements Buff
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnsafeDrop(" + delegate + ')';
|
||||
return "MakeInaccessibleOnDrop(" + delegate + ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ public class BufferCompositionTest extends BufferTestSupport {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitComponentsCeilMustGiveBufferWithFirstComponenForOffsetInFirstComponent() {
|
||||
public void splitComponentsCeilMustGiveBufferWithFirstComponentForOffsetInFirstComponent() {
|
||||
try (BufferAllocator allocator = BufferAllocator.heap();
|
||||
CompositeBuffer composite = CompositeBuffer.compose(allocator,
|
||||
allocator.allocate(8).send(),
|
||||
|
@ -1194,7 +1194,7 @@ public class BufferPrimitiveRelativeAccessorsTest extends BufferTestSupport {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("allocators")
|
||||
void relativeReadOfDoubleReadOnllyMustBoundsCheckWhenReadOffsetAndSizeIsBeyondWriteOffset(Fixture fixture) {
|
||||
void relativeReadOfDoubleReadOnlyMustBoundsCheckWhenReadOffsetAndSizeIsBeyondWriteOffset(Fixture fixture) {
|
||||
try (BufferAllocator allocator = fixture.createAllocator();
|
||||
Buffer buf = allocator.allocate(8)) {
|
||||
assertEquals(0, buf.readableBytes());
|
||||
|
@ -2119,7 +2119,7 @@ public abstract class AbstractByteBufTest {
|
||||
public void testSWARIndexOf() {
|
||||
ByteBuf buffer = newBuffer(16);
|
||||
buffer.clear();
|
||||
// Ensure the buffer is completely zero'ed.
|
||||
// Ensure the buffer is completely zeroed.
|
||||
buffer.setZero(0, buffer.capacity());
|
||||
buffer.writeByte((byte) 0); // 0
|
||||
buffer.writeByte((byte) 0);
|
||||
@ -2148,7 +2148,7 @@ public abstract class AbstractByteBufTest {
|
||||
@Test
|
||||
public void testIndexOf() {
|
||||
buffer.clear();
|
||||
// Ensure the buffer is completely zero'ed.
|
||||
// Ensure the buffer is completely zeroed.
|
||||
buffer.setZero(0, buffer.capacity());
|
||||
|
||||
buffer.writeByte((byte) 1);
|
||||
|
Loading…
Reference in New Issue
Block a user