You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/04/17 07:59:49 UTC

[GitHub] [flink] liyafan82 commented on a change in pull request #8194: [FLINK-12216][Runtime]Respect the number of bytes from input paramete…

liyafan82 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_r276121298
 
 

 ##########
 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:
   Yes. If a heap byte buffer is read only, its hasArray will be false. I have added the assertions to the UT. Thanks for the advice. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services