Re: Locks with try/finally

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Locks with try/finally

Chris Burnley
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.

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest