Skip to content

Commit

Permalink
[FLINK-17547][task][hotfix] Improve error handling
Browse files Browse the repository at this point in the history
1 catch one more invalid input in DataOutputSerializer.write
2 more informative error messages
  • Loading branch information
rkhachatryan authored and pnowojski committed May 19, 2020
1 parent 260ef2c commit 8548d37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public void write(byte[] b, int off, int len) throws IOException {

@Override
public void write(MemorySegment segment, int off, int len) throws IOException {
if (len < 0 || off > segment.size() - len) {
throw new ArrayIndexOutOfBoundsException();
if (len < 0 || off < 0 || off > segment.size() - len) {
throw new IndexOutOfBoundsException(String.format("offset: %d, length: %d, size: %d", off, len, segment.size()));
}
if (this.position > this.buffer.length - len) {
resize(len);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ else if (address > addressLimit) {
throw new IllegalStateException("segment has been freed");
}
else {
// index is in fact invalid
throw new IndexOutOfBoundsException();
throw new IndexOutOfBoundsException(String.format("pos: %d, length: %d, index: %d, offset: %d", pos, length, index, offset));
}
}

Expand Down

0 comments on commit 8548d37

Please sign in to comment.