Skip to content

Commit

Permalink
[FLINK-29347] [runtime] fix ByteStreamStateHandle#read(byte[] bytes, …
Browse files Browse the repository at this point in the history
…int offset, int count) return -1 when count = 0 and no data left.
  • Loading branch information
沈嘉琦 authored and Myasuka committed Oct 26, 2022
1 parent db46d43 commit 796017d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ 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));
try(FSDataInputStream in = handle.openInputStream()) {
byte[] dataGot = new byte[1];
assertEquals(0, in.read(dataGot, 0, 0)); // got return 0 because len == 0.
assertEquals(-1, in.read()); // got -1 because of EOF.
}
}
}

0 comments on commit 796017d

Please sign in to comment.