try {
} catch() {}
finally {
try {
} catch() { }
finally { }
}
Is it good to have the code like above?
It's ugly, but there are cases where you can't avoid it, especially in resource clean up where you have dependent resources and the clean up of one resource can throw an exception.
A typical example is tidying up ResultSet
, Statement
and Connection
objects in JDBC code. Closing the ResultSet
can throw an exception, but we'd still like to continue and close the Statement
and Connection