Shenjiaqi commented on code in PR #20860:
URL: https://github.com/apache/flink/pull/20860#discussion_r990613086
##########
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);
+ byte[] dataGot = new byte[1];
+ assertEquals(0, in.read(dataGot, 0, 0));
Review Comment:
> Do we need to test `assertEquals(0, in.read());`?
In this context, in.read() should return -1, bacause read always expect one
more byte.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]