Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close the outputstrean even thouht there were throwing an exception #6360

Closed
wants to merge 12 commits into from
Closed

Conversation

beijingling
Copy link
Contributor

No description provided.

IOUtils.copy(data, outputStream);
outputStream.close();
//outputStream.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we don't close it here, we risk an incomplete file when reading it a few statements later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,it‘s right.
but it will be closed in finally block.
if we colose here, there maybe throws an exception on before statement "IOUtils.copy(data, outputStream);".
closing it on the finally block,it will be execute in anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The finally block is too late. It needs to be closed earlier. By the time that the finally block is executed, we have already tried to read the created (incomplete) file.

@beijingling beijingling closed this by deleting the head repository Apr 12, 2023
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.

None yet

2 participants