StephanEwen commented on a change in pull request #8194: 
[FLINK-12216][Runtime]Respect the number of bytes from input paramete…
URL: https://github.com/apache/flink/pull/8194#discussion_r276115442
 
 

 ##########
 File path: 
flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java
 ##########
 @@ -77,4 +77,32 @@ public void testHybridHeapSegmentSpecifics() {
                assertEquals(3, buf2.position());
                assertEquals(7, buf2.limit());
        }
+
+       @Test
+       public void testReadOnlyByteBufferPut() {
+               final byte[] buffer = new byte[100];
+               HybridMemorySegment seg = new HybridMemorySegment(buffer);
+
+               String content = "hello world";
+               ByteBuffer bb = ByteBuffer.allocate(20);
+               bb.put(content.getBytes());
+               bb.rewind();
+
+               int offset = 10;
+               int numBytes = 5;
+               seg.put(offset, bb.asReadOnlyBuffer(), numBytes);
 
 Review comment:
   Are we certain that `bb.asReadOnlyBuffer()` returns a buffer that is neither 
direct, nor has an array? Only on that case would it go into the affected code 
branch.
   
   The test should guard its assumption like:
   ```java
   ByteBuffer buf = bb.asReadOnlyBuffer();
   assertFalse(buf.isDirect());
   assertFalse(buf.hasArray());
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to