Added missing assertions

This commit is contained in:
Collin Smith 2020-08-16 02:33:47 -07:00
parent 2eb773633a
commit 506773d25c
2 changed files with 3 additions and 0 deletions

View File

@ -217,6 +217,7 @@ public class ByteInput {
* @see ByteBuf#readSlice(int)
*/
public ByteInput readSlice(long numBytes) {
assert aligned() : "not aligned";
assert numBytes <= Integer.MAX_VALUE : "ByteBuf only supports int length";
final int mark = updateMark(); // updates mark to start offset of slice
final ByteBuf slice = buffer.readSlice((int) numBytes);

View File

@ -51,6 +51,7 @@ public class ByteOutput {
}
public ByteOutput skipBytes(int bytes) {
assert aligned() : "not aligned";
incrementBitsWritten((long) bytes * Byte.SIZE);
buffer.writeZero(bytes);
return this;
@ -108,6 +109,7 @@ public class ByteOutput {
}
public ByteOutput writeString(CharSequence chars) {
assert aligned() : "not aligned";
incrementBitsWritten((long) chars.length() * Byte.SIZE);
buffer.writeCharSequence(chars, CharsetUtil.US_ASCII);
return this;