From b5c87b0f9c467aa7bb29eac90518bcf2ab69dad7 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 18 Jan 2013 13:34:00 +0900 Subject: [PATCH] Fix failing tests --- buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java b/buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java index 6dcd87ac23..0ccc8727b7 100644 --- a/buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java @@ -976,7 +976,10 @@ public abstract class AbstractByteBuf implements ByteBuf { protected final void checkIndex(int index, int fieldLength) { checkUnfreed(); - if (index < 0 || index > capacity() - fieldLength || fieldLength < 0) { + if (fieldLength < 0) { + throw new IllegalArgumentException("length: " + fieldLength + " (expected: >= 0)"); + } + if (index < 0 || index > capacity() - fieldLength) { throw new IndexOutOfBoundsException(String.format( "index: %d, length: %d (expected: range(0, %d))", index, fieldLength, capacity())); }