Skip to content
Snippets Groups Projects
Commit 2ddaaadc authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Prevented NullPointerException when closing a null session

Since the end-state of closeSession() is to have a null session, if
session is already null, there is nothing to do.
parent 2feb681f
Branches
Tags
No related merge requests found
...@@ -28,6 +28,7 @@ public class FruitPopulator { ...@@ -28,6 +28,7 @@ public class FruitPopulator {
} }
public static void closeSession(Session session) { public static void closeSession(Session session) {
if (session != null) {
try { try {
session.close(); session.close();
} catch (HibernateException hibernateException) { } catch (HibernateException hibernateException) {
...@@ -38,6 +39,7 @@ public class FruitPopulator { ...@@ -38,6 +39,7 @@ public class FruitPopulator {
session = null; session = null;
} }
} }
}
private void makeFruitSalad() { private void makeFruitSalad() {
Session session = getSession(); Session session = getSession();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment