barry3406 opened a new pull request, #15969: URL: https://github.com/apache/lucene/pull/15969
### Description Fixes #15730. `RandomAccessInput` specifies that absolute reads "have no concept of file position" — the input's file pointer must not change. `MemorySegmentIndexInput.readShort(long)`, `readInt(long)` and `readLong(long)` violate this when the read crosses a memory-segment boundary: they fall back to `setPos(pos, si)` followed by a relative `readShort/readInt/readLong`, which mutate `curSegmentIndex`, `curSegment` and `curPosition`. From the reporter's repro, `input.readInt(14)` on two adjacent 16-byte segments leaves `getFilePointer()` at 18 instead of the original 0. This PR saves the three fields before entering the boundary fallback and restores them in a `finally` block. The fast in-segment path is unchanged, so there is no performance impact on the common case, and the fallback only ever runs at chunk boundaries or past-EOF — both rare. ### Tests Added `TestMultiMMap.testAbsoluteReadDoesNotModifyPositionAcrossBoundary` exercising `readInt/readShort/readLong` at and across the chunk boundary (including starting from a non-zero file pointer), and also verifying that the fallback still returns the correct value. Verified the test fails without the fix (`expected:<0> but was:<18>`) and passes with it. `:lucene:core:test --tests "org.apache.lucene.store.TestMultiMMap"` (75 tests), `:lucene:core:check -x test` (forbiddenApis, ecjLint), and `./gradlew tidy` all pass locally. CHANGES.txt entry added under 11.0.0 Bug Fixes. -- 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]
