We've expanded our news coverage and improved our search! Visit
news.oreilly.com for the latest or search for all things across O'Reilly!
Article:
 |
|
Five Things I Love About Spring
|
| Subject: |
|
Bug in "The Old Way" Code |
| Date: |
|
2005-11-13 08:29:41 |
| From: |
|
DavidPeterson
|
|
|
Your code:
public List getBikesOldWay() throws Exception {
List bikes = null;
Session s = null;
try {
s = mySessionFactory.openSession( );
bikes = s.find("from Bike");
}catch (Exception ex) {
//handle exception gracefully
}finally {
s.close( );
}
return bikes;
}
This will throw a NullPointerException in the finally block if the session factory throws an exception when opening a session, i.e. it will conceal the true exception.
Is this how Spring does it too?
|