Use try-with-resources
MSALRefactor 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. UseTryWithResourcesmod run . --recipe= org. openrewrite. staticanalysis. UseTryWithResourcesInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.