Shenjiaqi commented on code in PR #20860: URL: https://github.com/apache/flink/pull/20860#discussion_r990613581
########## flink-runtime/src/test/java/org/apache/flink/runtime/state/memory/ByteStreamStateHandleTest.java: ########## @@ -172,4 +172,15 @@ public void testBulkReadINdexOutOfBounds() throws IOException { // expected } } + + @Test + public void testStreamWithEmptyByteArray() throws IOException { + final byte[] data = new byte[0]; + final ByteStreamStateHandle handle = new ByteStreamStateHandle("name", data); + + FSDataInputStream in = handle.openInputStream(); Review Comment: Add try with resource when using FSDataInputStream. ########## flink-runtime/src/test/java/org/apache/flink/runtime/state/memory/ByteStreamStateHandleTest.java: ########## @@ -172,4 +172,15 @@ public void testBulkReadINdexOutOfBounds() throws IOException { // expected } } + + @Test + public void testStreamWithEmptyByteArray() throws IOException { + final byte[] data = new byte[0]; + final ByteStreamStateHandle handle = new ByteStreamStateHandle("name", data); + + FSDataInputStream in = handle.openInputStream(); + in.seek(0); + byte[] dataGot = new byte[1]; + assertEquals(0, in.read(dataGot, 0, 0)); Review Comment: In this context, in.read() should return -1, bacause read always expect one more byte. ########## flink-runtime/src/test/java/org/apache/flink/runtime/state/memory/ByteStreamStateHandleTest.java: ########## @@ -172,4 +172,15 @@ public void testBulkReadINdexOutOfBounds() throws IOException { // expected } } + + @Test + public void testStreamWithEmptyByteArray() throws IOException { + final byte[] data = new byte[0]; + final ByteStreamStateHandle handle = new ByteStreamStateHandle("name", data); + + FSDataInputStream in = handle.openInputStream(); + in.seek(0); Review Comment: this can be removed. -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org