Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4593#discussion_r148209947
  
    --- Diff: 
flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java 
---
    @@ -306,6 +307,9 @@ public final void get(int offset, ByteBuffer target, 
int numBytes) {
                if ((offset | numBytes | (offset + numBytes)) < 0) {
                        throw new IndexOutOfBoundsException();
                }
    +           if (target.isReadOnly()) {
    --- End diff --
    
    you are right - the non-direct buffers path is based on 
`ByteBuffer#array()` which will throw a `ReadOnlyBufferException` for read-only 
buffers, so it really is enough in the direct buffers code path where the 
`UNSAFE.copyMemory` is not checking the source pointer (how should it?!)


---

Reply via email to