Skip to content

[Bug] FileIndexFormat.Reader leaks input stream when construction fails with a runtime exception #8765

Description

@thswlsqls

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version
master @ 345526e

Compute Engine
Engine-agnostic (core)

Minimal reproduce step
Call FileIndexFormat.createReader(seekableInputStream, rowType) on a corrupt or wrong-version index file. FileIndexFormat.Reader.<init> (paimon-common FileIndexFormat.java lines 248-261) throws a RuntimeException from the magic check ("This file is not file index file.") or the version check, both inside the constructor's try block. The only catch (IOException e) (line 282) closes the owned stream, but a RuntimeException escapes it uncaught.

What doesn't meet your expectations?
Because the constructor throws before returning, the caller's try-with-resources never binds the Reader, so its close() never runs and the SeekableInputStream (a real file descriptor) leaks. The IOException path already closes it.

Anything else?
Fix: widen the catch to IOException | RuntimeException so the stream is closed on both failure paths, mirroring the existing IOException branch.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions