Skip to content
New issue

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

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

Already on GitHub? # to your account

Use try-with-resources or close this "FileOutputStream" in a "finally" clause. #5878

Closed
MinaQin opened this issue May 12, 2022 · 0 comments · Fixed by #6147
Closed

Use try-with-resources or close this "FileOutputStream" in a "finally" clause. #5878

MinaQin opened this issue May 12, 2022 · 0 comments · Fixed by #6147

Comments

@MinaQin
Copy link
Contributor

MinaQin commented May 12, 2022

Code Path: confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
image
Connections, streams, files, and other classes that implement the Closeable interface or its super-interface, AutoCloseable, needs to be closed after use. Further, that close call must be made in a finally block otherwise an exception could keep the call from being made. Preferably, when class implements AutoCloseable, resource should be created using "try-with-resources" pattern and will be closed automatically.

Failure to properly close resources will result in a resource leak which could bring first the application and then perhaps the box the application is on to their knees.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants