Details
-
Task
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
-
Pulsar
-
Pulsar 260 - BEST, Pulsar 261 - BEST+
Description
Sonarqube reported several classes that implement the Closeable which are used without try-with-resources or finally clause. Update these occurrences to follow the compliant code pattern
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.