Skip to content

Commit

Permalink
Do not throw EOF exception on checksum stream read
Browse files Browse the repository at this point in the history
Currently BufferedChecksumStreamInput#read will throw EOFException
because it delegates to #readByte(). However, when the end of stream has
been reached for #read() this method should return -1.
  • Loading branch information
Tim-Brooks committed Jun 27, 2023
1 parent 6e6fd92 commit 9995c1a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.common.io.stream.FilterStreamInput;
import org.elasticsearch.common.io.stream.StreamInput;

import java.io.EOFException;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
Expand Down Expand Up @@ -101,7 +102,11 @@ public void reset() throws IOException {

@Override
public int read() throws IOException {
return readByte() & 0xFF;
try {
return readByte() & 0xFF;
} catch (EOFException e) {
return -1;
}
}

@Override
Expand Down

0 comments on commit 9995c1a

Please sign in to comment.