Skip to content

Commit

Permalink
RefreshObject: Fix resource leak
Browse files Browse the repository at this point in the history
Coverity report:
CID 44605 (#1 of 1): Resource leak (RESOURCE_LEAK)

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 3, 2016
1 parent e4f5d16 commit b60e771
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Goobi/src/de/sub/goobi/helper/RefreshObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,29 @@ public static void refreshProcess_GUI(int processID) {
if(logger.isDebugEnabled()){
logger.debug("refreshing process with id " + processID);
}
Session session = null;
boolean needsClose = false;
try {
Session session = Helper.getHibernateSession();
session = Helper.getHibernateSession();
if (session == null || !session.isOpen() || !session.isConnected()) {
logger.debug("session is closed, creating a new session");
HibernateUtilOld.rebuildSessionFactory();
session = HibernateUtilOld.getSessionFactory().openSession();
needsClose = true;
}
Prozess o = (Prozess) session.get(Prozess.class, processID);
logger.debug("loaded process");
session.refresh(o);
logger.debug("refreshed process");
// session.close();
// logger.debug("closed session");
if (needsClose) {
session.close();
logger.debug("closed session");
}
} catch (Throwable e) {
logger.error("cannot refresh process with id " + processID);
if (needsClose) {
session.close();
}
}
}

Expand Down

0 comments on commit b60e771

Please sign in to comment.