ThorneANN opened a new issue, #2790: URL: https://github.com/apache/fluss/issues/2790
### Search before asking - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar. ### Fluss version 0.9.0 (latest release) ### Please describe the bug 🐞 Issue: In the constructor, after tableRead.createReader() creates a RecordReader and converts it to a CloseableIterator via toCloseableIterator(), if the subsequent PaimonRowAsFlussRecordIterator construction throws an exception, the CloseableIterator resource is never closed, causing a resource leak. ``` org.apache.paimon.reader.RecordReader<InternalRow> recordReader = tableRead.createReader(split.dataSplit()); iterator = new PaimonRecordReader.PaimonRowAsFlussRecordIterator( recordReader.toCloseableIterator(), paimonRowType); ``` Root Cause: The toCloseableIterator() call returns a resource that must be closed. If an exception occurs during the PaimonRowAsFlussRecordIterator construction, the constructor fails before the iterator is assigned to the field, leaving no way for the caller to close the leaked resource. ### Solution Extract the CloseableIterator to a local variable and wrap the construction in a try-catch block to ensure proper cleanup on failure: ``` org.apache.paimon.reader.RecordReader<InternalRow> recordReader = tableRead.createReader(split.dataSplit()); org.apache.paimon.utils.CloseableIterator<InternalRow> closeableIterator = recordReader.toCloseableIterator(); try { iterator = new PaimonRecordReader.PaimonRowAsFlussRecordIterator( closeableIterator, paimonRowType); } catch (Throwable t) { try { closeableIterator.close(); } catch (Exception closeException) { t.addSuppressed(closeException); } throw t; } ``` ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
