Skip to content

Commit

Permalink
Improve the log of ByteArrays#validateBounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoy committed Sep 18, 2017
1 parent f1181ac commit 99cc177
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pcap4j-core/src/main/java/org/pcap4j/util/ByteArrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,12 @@ public static void validateBounds(byte[] arr, int offset, int len) {
throw new IllegalArgumentException("arr is empty.");
}
if (len == 0) {
throw new IllegalArgumentException("length is zero.");
StringBuilder sb = new StringBuilder(100);
sb.append("length is zero. offset: ")
.append(offset)
.append(", arr: ")
.append(toHexString(arr, ""));
throw new IllegalArgumentException(sb.toString());
}
if (offset < 0 || len < 0 || offset + len > arr.length) {
StringBuilder sb = new StringBuilder(100);
Expand All @@ -1067,7 +1072,9 @@ public static void validateBounds(byte[] arr, int offset, int len) {
.append(", offset: ")
.append(offset)
.append(", len: ")
.append(len);
.append(len)
.append(", arr: ")
.append(toHexString(arr, ""));
throw new ArrayIndexOutOfBoundsException(sb.toString());
}
}
Expand Down

0 comments on commit 99cc177

Please sign in to comment.