[concurrency-interest] Re: Locks with try/finally

Chris Burnley chris.burnley at gmail.com
Tue Jul 19 05:53:47 EDT 2005


If find the best way to do it is something like this:

Connection connection = ds.getConnection();
try {
    connection.xxxx();
}
finally {
   connection.close();
}


If getConnection fails and throws an exception then flow control will
never go below this line and hence there is no risk of nullpointer in
the finally.



More information about the Concurrency-interest mailing list