Question: how try with resources works internally?
Answer: Throwable. That is the concept of try-with-resources. If an exception is thrown in the try block, then the control will be transferred to catch. In between the jump to catch block the close() will be internally invoked for the registered resources.