Use try-with-resources

MSAL

Refactor try/finally blocks to use try-with-resources when the finally block only closes an AutoCloseable resource. Try-with-resources guarantees that resources are closed even when exceptions occur, eliminating an entire class of resource-leak bugs that manual finally blocks are prone to.

org.openrewrite.staticanalysis.UseTryWithResources
mod run . --recipe=org.openrewrite.staticanalysis.UseTryWithResources

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.