Skip to content

Close FileOutputStream in downloadFileWithProgress#1762

Open
tejasae-afk wants to merge 1 commit intodevonfw:mainfrom
tejasae-afk:fix/close-fileoutputstream-in-down
Open

Close FileOutputStream in downloadFileWithProgress#1762
tejasae-afk wants to merge 1 commit intodevonfw:mainfrom
tejasae-afk:fix/close-fileoutputstream-in-down

Conversation

@tejasae-afk
Copy link

downloadFileWithProgressBar is close, but the resource opened there can leak if downloadFileWithProgressBar exits on an error path. I moved the allocation into try-with-resources so cleanup happens on every exit path.

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@hohwille
Copy link
Member

@tejasae-afk thank you for contributing to IDEasy and providing this PR.
However, I slightly disagree with your analysis.
According to how try-with-resource works:

all closable resources opened by the try block will be guaranteed to be closed if they could be created.
This includes all error paths even those creating further resources in the try block.
Nesting try-with-resources blocks is IMHO not needed here.

BTW: It seems your code change does not even compile and was thus untested.

If you are still thinking I am wrong here, please explain further and fix your code.
Then I am more than willing to merge.

@hohwille hohwille added the waiting for feedback Pending for details/answers to further process this issue. label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting for feedback Pending for details/answers to further process this issue.

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

3 participants