diff --git a/core/src/com/riiablo/io/nio/ByteInput.java b/core/src/com/riiablo/io/nio/ByteInput.java index a2df0b3a..3e268e4c 100644 --- a/core/src/com/riiablo/io/nio/ByteInput.java +++ b/core/src/com/riiablo/io/nio/ByteInput.java @@ -18,19 +18,20 @@ import com.riiablo.util.DebugUtils; */ // TODO: improve placeholder documentation public class ByteInput { - private static final ByteInput EMPTY_BYTEINPUT = new ByteInput(Unpooled.EMPTY_BUFFER); + private static final ByteInput EMPTY_BYTEINPUT = new ByteInput(Unpooled.EMPTY_BUFFER.asReadOnly()); public static ByteInput emptyByteInput() { return EMPTY_BYTEINPUT; } public static ByteInput wrap(byte[] bytes) { - return bytes == null ? emptyByteInput() : new ByteInput(Unpooled.wrappedBuffer(bytes)); + return bytes == null ? emptyByteInput() : new ByteInput(Unpooled.wrappedBuffer(bytes).asReadOnly()); } private final ByteBuf buffer; private BitInput bitInput; ByteInput(ByteBuf buffer) { + assert buffer.isReadOnly() : "buffer should be tagged ByteBuf#asReadOnly()"; this.buffer = buffer; }