Get the tests passing again
This commit is contained in:
parent
c840a41e31
commit
60df2393f3
@ -891,6 +891,9 @@ public final class CompositeBuffer extends ResourceSupport<Buffer, CompositeBuff
|
||||
throw new IllegalArgumentException("The split offset cannot be greater than the buffer capacity, " +
|
||||
"but the split offset was " + splitOffset + ", and capacity is " + capacity() + '.');
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw attachTrace(bufferIsClosed(this));
|
||||
}
|
||||
if (!isOwned()) {
|
||||
throw new IllegalStateException("Cannot split a buffer that is not owned.");
|
||||
}
|
||||
|
@ -459,6 +459,9 @@ class NioBuffer extends ResourceSupport<Buffer, NioBuffer> implements Buffer, Re
|
||||
throw new IllegalArgumentException("The split offset cannot be greater than the buffer capacity, " +
|
||||
"but the split offset was " + splitOffset + ", and capacity is " + capacity() + '.');
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw attachTrace(bufferIsClosed(this));
|
||||
}
|
||||
if (!isOwned()) {
|
||||
throw attachTrace(new IllegalStateException("Cannot split a buffer that is not owned."));
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ public abstract class ResourceSupport<I extends Resource<I>, T extends ResourceS
|
||||
*/
|
||||
@Override
|
||||
public final Send<I> send() {
|
||||
if (acquires < 0) {
|
||||
throw attachTrace(createResourceClosedException());
|
||||
}
|
||||
if (!isOwned()) {
|
||||
throw notSendableException();
|
||||
}
|
||||
|
@ -506,6 +506,9 @@ class UnsafeBuffer extends ResourceSupport<Buffer, UnsafeBuffer> implements Buff
|
||||
throw new IllegalArgumentException("The split offset cannot be greater than the buffer capacity, " +
|
||||
"but the split offset was " + splitOffset + ", and capacity is " + capacity() + '.');
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw attachTrace(bufferIsClosed(this));
|
||||
}
|
||||
if (!isOwned()) {
|
||||
throw attachTrace(new IllegalStateException("Cannot split a buffer that is not owned."));
|
||||
}
|
||||
|
@ -584,6 +584,9 @@ class MemSegBuffer extends ResourceSupport<Buffer, MemSegBuffer> implements Buff
|
||||
throw new IllegalArgumentException("The split offset cannot be greater than the buffer capacity, " +
|
||||
"but the split offset was " + splitOffset + ", and capacity is " + capacity() + '.');
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw attachTrace(bufferIsClosed(this));
|
||||
}
|
||||
if (!isOwned()) {
|
||||
throw attachTrace(new IllegalStateException("Cannot split a buffer that is not owned."));
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package io.netty.buffer.api.tests;
|
||||
|
||||
import io.netty.buffer.api.Buffer;
|
||||
import io.netty.buffer.api.BufferAllocator;
|
||||
import io.netty.buffer.api.BufferClosedException;
|
||||
import io.netty.buffer.api.BufferRef;
|
||||
import io.netty.buffer.api.Send;
|
||||
import io.netty.buffer.api.internal.ResourceSupport;
|
||||
@ -110,9 +111,9 @@ public class BufferSendTest extends BufferTestSupport {
|
||||
try (BufferAllocator allocator = fixture.createAllocator();
|
||||
Buffer buf = allocator.allocate(8)) {
|
||||
var send = buf.send();
|
||||
var exc = assertThrows(IllegalStateException.class, () -> buf.send());
|
||||
var exc = assertThrows(BufferClosedException.class, () -> buf.send());
|
||||
send.receive().close();
|
||||
assertThat(exc).hasMessageContaining("Cannot send()");
|
||||
assertThat(exc).hasMessageContaining("closed");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user