Skip to content

[mosaic] Clean up reader resources on construction failure#8144

Open
QuakeWang wants to merge 1 commit into
apache:masterfrom
QuakeWang:mosaic-reader-cleanup
Open

[mosaic] Clean up reader resources on construction failure#8144
QuakeWang wants to merge 1 commit into
apache:masterfrom
QuakeWang:mosaic-reader-cleanup

Conversation

@QuakeWang
Copy link
Copy Markdown
Contributor

Purpose

MosaicReaderFactory creates a MosaicInputFileAdapter before constructing MosaicRecordsReader. If MosaicRecordsReader failed during construction, callers could not receive the reader instance and therefore could not close it.

The old constructor only closed the allocator when MosaicReader.open threw an Exception. It did not close the input adapter, did not handle Error failures such as native loading errors, and did not clean up if initialization failed after the native reader had already been created.

This patch initializes reader resources through local variables and assigns final fields only after construction succeeds. On construction failure, it closes the created native reader, allocator, and input adapter while preserving the original exception.

Tests

  • mvn -pl paimon-mosaic -am -Pfast-build -DfailIfNoTests=false -Dtest=MosaicRecordsReaderTest test
  • mvn -pl paimon-mosaic -am -DfailIfNoTests=false -Dtest=MosaicRecordsReaderTest test

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant