Skip to content

[Bug] CompositeInputStream.close() may leak underlying streams when one close() throws #16117

@iamsanjaymalakar

Description

@iamsanjaymalakar

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo Java 3.3, Ubuntu 20.04

Steps to reproduce this issue

Resource leak, non-deterministic.

What you expected to happen

CompositeInputStream.close() should attempt to close all underlying streams, even if one close() throws. After trying all closes, it should throw the first IOException and attach later close failures as suppressed exceptions (if any).

This prevents partial cleanup and potential resource leaks.

Anything else

Current behavior: CompositeInputStream.close() stops at the first IOException, leaving remaining streams unclosed.

Frequency: Every time an underlying stream’s close() throws.

Proposed fix: Wrap each close() in try/catch while draining the queue, collect the first IOException, suppress subsequent failures, and throw after attempting all closes.

Do you have a (mini) reproduction demo?

  • Yes, I have a minimal reproduction demo to help resolve this issue more effectively!

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedEverything needs help from contributors

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions