Skip to content

Commit

Permalink
apacheGH-3080: Tests of the new input stream.
Browse files Browse the repository at this point in the history
Based of the H2 stream test suite but
* parameterized for on/off heap
* expect no changes in buffer contents on out of range reads.

Still one test failure.
  • Loading branch information
steveloughran committed Nov 27, 2024
1 parent f34a341 commit 789e185
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,19 @@ public FSDataInputStream getStream() {
*/
@Override
public void readFully(final ByteBuffer buf) throws EOFException, IOException {
// use ByteBufferPositionedReadable.readFully()
final FSDataInputStream stream = getStream();
performRead(getStream(), buf);
}

/**
* Read the buffer fully through use of {@code ByteBufferPositionedReadable.readFully()}
* at the current location.
*
* @param buf a byte buffer to fill with data from the stream
* @throws EOFException the buffer length is greater than the file length
* @throws IOException other IO problems.
*/
// Visible for testing
static void performRead(final FSDataInputStream stream, final ByteBuffer buf) throws IOException {
// remember the current position
final long pos = stream.getPos();
final int size = buf.remaining();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,4 @@ static void rejectNegativePosition(final long pos) throws EOFException {
throw new EOFException("Seek before file start: " + pos);
}
}

}
Loading

0 comments on commit 789e185

Please sign in to comment.