PDGGK opened a new pull request, #9462:
URL: https://github.com/apache/paimon/pull/9462
### Purpose
`FileIndexPredicate` opens a stream and hands it straight to the reader:
```java
public FileIndexPredicate(Path path, FileIO fileIO, RowType fileRowType)
throws IOException {
this(fileIO.newInputStream(path), fileRowType);
this.path = path;
}
public FileIndexPredicate(SeekableInputStream inputStream, RowType
fileRowType) {
this.reader = FileIndexFormat.createReader(inputStream, fileRowType);
}
```
`FileIndexFormat.Reader` validates the file header and rejects anything that
is not an index file:
```java
if (magic != MAGIC) {
throw new RuntimeException("This file is not file index file.");
}
```
When that fires the constructor never returns, so nothing holds a reference
to the stream and nobody can close it. A corrupted or truncated index file
leaks a file handle per attempt, and scans retry per file.
`BitmapIndexReader` and `BTreeIndexReader` already guard the same sequence,
so this makes the three agree.
### Tests
`FileIndexPredicateCloseTest#testFailedConstructionReleasesTheStream` wraps
the stream so closes are counted, feeds bytes that are not an index file, and
asserts the construction fails with `not file index file` and the stream is
still released.
Reverting the change turns it red on the close counter (`Expecting
AtomicInteger(0) to have value: 1`).
`mvn test -pl paimon-common -Dtest='org.apache.paimon.fileindex.**'` — 68
tests, all passing. spotless and checkstyle clean.
--
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]