Re:Exception Safety, Garbage Collection etc. (a.k.a. Why Doe...
by mynameishere on Friday May 06, 2011 @01:46PM
(#2521761)
I was thinking the same thing, but replace your finally block with,
...and let that handle all the possible issues.
[ Parent
| on HN ]
Re:Exception Safety, Garbage Collection etc. (a.k.a. Why Doe...
by reverend_gonzo on Friday May 06, 2011 @02:04PM
(#2521840)
I've taken Groovy's with... syntax and built utils that are ie:
public void withConnection(Callback<Connection> callback) { Connection connection = createConnection(); try { callback.call(connection); } finally { connection.dispose(); } }
Once Java actually gets closures it'll make this soooo much nicer.