DEV Community

Discussion on: Exception Scenarios for Java's try-with-resources

Collapse
 
jingxue profile image
Jing Xue

Interesting read. Thanks for trying out these scenarios. I like how it suppresses both close failures when there is a work failure, and let the work failure propagate up. That is what the caller would most likely care about.

I was a little surprised by the r2 create failure scenario, where it closes r1 before the catch block. I would have thought the closure would happen in an auto-generated finally block. However come to think of it, that actually makes sense because it gives the catch block a chance to handle close failures.