try-with-resources and null resource

Roel Spilker R.Spilker at topdesk.com
Thu Jan 27 07:44:43 PST 2011


> Is anyone actually against the "don't call close on null resource"? My first reaction was against, but Bruce convinced me easily.


In Project Lombok (http://projectlombok.org) we have already about a year of field experience with ARM blocks using the @Cleanup annotation. We've added the null-check in the finally block at the request of our users. 

One thing to take into account is that code analysers that use the class file could warn that the null check is not necessary. In the class file there is no (reliable) distinction between a hand-coded try block and an ARM block. 

Just to be sure: I am all for "don't call close on null resource", I just wanted to give a "heads up".

Roel




More information about the coin-dev mailing list