This is an automated email from the ASF dual-hosted git repository.

pnowojski pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 9fedade3f8ec4b3dad0e9d7d0a6751fc2c66a121
Author: Roman Khachatryan <[email protected]>
AuthorDate: Thu May 7 09:33:25 2020 +0200

    [FLINK-17547][task][hotfix] Improve error handling
    1 catch one more invalid input in DataOutputSerializer.write
    2 more informative error messages
---
 .../main/java/org/apache/flink/core/memory/DataOutputSerializer.java  | 4 ++--
 .../main/java/org/apache/flink/core/memory/HybridMemorySegment.java   | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git 
a/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
 
b/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
index 85fd767..1255fc3 100644
--- 
a/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
+++ 
b/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
@@ -157,8 +157,8 @@ public class DataOutputSerializer implements 
DataOutputView, MemorySegmentWritab
 
        @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);
diff --git 
a/flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
 
b/flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
index fb7a4ba..53e8cfd 100644
--- 
a/flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
+++ 
b/flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java
@@ -195,8 +195,7 @@ public final class HybridMemorySegment extends 
MemorySegment {
                        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));
                }
        }
 

Reply via email to