Fixed another two contract violations in AbstractChannelBuffer

This commit is contained in:
Trustin Lee 2008-08-11 03:36:49 +00:00
parent d882e4f27c
commit 0a594a27d5

View File

@ -310,6 +310,9 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
}
public void readBytes(ChannelBuffer dst, int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException();
}
readBytes(dst, dst.writerIndex(), length);
dst.writerIndex(dst.writerIndex() + length);
}
@ -397,6 +400,9 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
}
public void writeBytes(ChannelBuffer src, int length) {
if (length > src.readableBytes()) {
throw new IndexOutOfBoundsException();
}
writeBytes(src, src.readerIndex(), length);
src.readerIndex(src.readerIndex() + length);
}