Add IndexOutOfBoundsException error message (#10405)
Motivation: We should provide details about why an IOOBE was thrown Modification: Add IndexOutOfBoundsException error information in io.netty.util.internal.AppendableCharSequence and io.netty.handler.codec.CodecOutputList class Result: Easier to debug
This commit is contained in:
parent
cd0203b5c7
commit
9f89eb6429
@ -206,7 +206,8 @@ final class CodecOutputList extends AbstractList<Object> implements RandomAccess
|
||||
|
||||
private void checkIndex(int index) {
|
||||
if (index >= size) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
throw new IndexOutOfBoundsException("expected: index < ("
|
||||
+ size + "),but actual is (" + size + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,8 @@ public final class AppendableCharSequence implements CharSequence, Appendable {
|
||||
@Override
|
||||
public AppendableCharSequence append(CharSequence csq, int start, int end) {
|
||||
if (csq.length() < end) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
throw new IndexOutOfBoundsException("expected: csq.length() >= ("
|
||||
+ end + "),but actual is (" + csq.length() + ")");
|
||||
}
|
||||
int length = end - start;
|
||||
if (length > chars.length - pos) {
|
||||
@ -138,7 +139,8 @@ public final class AppendableCharSequence implements CharSequence, Appendable {
|
||||
public String substring(int start, int end) {
|
||||
int length = end - start;
|
||||
if (start > pos || length > pos) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
throw new IndexOutOfBoundsException("expected: start and length <= ("
|
||||
+ pos + ")");
|
||||
}
|
||||
return new String(chars, start, length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user