Exploring try-with-resources and dispose() method interaction