apache/dubbo

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

Open

#16117 opened on Mar 7, 2026

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Java (41,524 stars) (26,453 forks)batch import
help wanted

Description

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

Contributor guide