You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/08/29 06:20:57 UTC
[PR] [common] Release the input stream when FileIndexPredicate fails to open it [paimon]
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [common] Release the input stream when FileIndexPredicate fails to open it [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #9462:
URL: https://github.com/apache/paimon/pull/9462
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [common] Release the input stream when FileIndexPredicate fails to open it [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #9462:
URL: https://github.com/apache/paimon/pull/9462#issuecomment-5462527535
+1
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org