Skip to content

SplitInputStream: close all underlying streams even if one close fails#1869

Merged
MuntashirAkon merged 1 commit intoMuntashirAkon:masterfrom
iamsanjaymalakar:master
Mar 1, 2026
Merged

SplitInputStream: close all underlying streams even if one close fails#1869
MuntashirAkon merged 1 commit intoMuntashirAkon:masterfrom
iamsanjaymalakar:master

Conversation

@iamsanjaymalakar
Copy link
Contributor

Problem

SplitInputStream wraps multiple InputStreams. In close(), it closes them sequentially without handling exceptions. If one close() throws, the method exits immediately and the remaining streams are never closed.

Fix

  • Wrap each stream.close() in a try/catch.
  • Continue closing the remaining streams even after a failure.
  • After attempting all closes, throw the first exception (and attach later ones as suppressed, if present).

Signed-off-by: Sanjay Malakar <iamsanjaymalakar@gmail.com>
@MuntashirAkon MuntashirAkon merged commit c24253d into MuntashirAkon:master Mar 1, 2026
5 checks passed
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.

2 participants