Skip to content

Commit d5066d4

Browse files
authored
Allow for mark == bytes.length. (#128340) (#128466)
In the case that the mark is at the very end of the stream, the slice's stream could already be closed by the time we call reset(), and so the stream must be reopened.
1 parent a4d21b2 commit d5066d4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/src/test/java/org/elasticsearch/index/snapshots/blobstore/SlicedInputStreamTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ protected InputStream openSlice(int slice) throws IOException {
178178
// Reset
179179
input.reset();
180180
int slicesOpenedAfterReset = streamsOpened.size();
181-
assert moreBytes > 0 || mark == 0 || slicesOpenedAfterReset == slicesOpenedAtMark : "Reset at mark should not re-open slices";
181+
assert moreBytes > 0 || mark == 0 || mark == bytes.length || slicesOpenedAfterReset == slicesOpenedAtMark
182+
: "Reset at mark should not re-open slices";
182183

183184
// Read all remaining bytes, which should be the bytes from mark up to the end
184185
final int remainingBytes = bytes.length - mark;

0 commit comments

Comments
 (0)