uschindler commented on code in PR #15969:
URL: https://github.com/apache/lucene/pull/15969#discussion_r3109561104
##########
lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java:
##########
@@ -204,4 +204,57 @@ private static void assertCorrectImpl(boolean isSingle,
IndexInput ii) {
"Require a multi impl, got " + clazz,
clazz.getSimpleName().matches("Multi\\w+Impl"));
}
}
+
+ // GITHUB#15730: MemorySegmentIndexInput's absolute read methods must not
modify the input's
+ // file pointer, even when the read crosses a memory-segment boundary and
the implementation
+ // has to fall back to seek + relative read.
+ public void testAbsoluteReadDoesNotModifyPositionAcrossBoundary() throws
IOException {
+ final int chunkSize = 16;
+ try (Directory dir =
+ getDirectory(createTempDir("testAbsoluteReadDoesNotModifyPosition"),
chunkSize)) {
+ try (IndexOutput out = dir.createOutput("file", IOContext.DEFAULT)) {
+ for (int i = 0; i < chunkSize * 2; i++) {
+ out.writeByte((byte) i);
+ }
+ }
+ try (IndexInput input = dir.openInput("file", IOContext.DEFAULT)) {
+ // ensure we really are exercising the multi-segment impl
+ assertCorrectImpl(false, input);
+ RandomAccessInput rai = (RandomAccessInput) input;
Review Comment:
This line needs to be:
```java
RandomAccessInput rai = input.randomAccessSlice(0, input.length());
```
Then test will pass without any fixes. Casting just because it works is not
allowed!
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]