Related with issue 34453:Added missing catch block for the commitAndClose
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Fri, 16 Dec 2016 13:22:24 +0100
changeset 30975 56b8427f2716
parent 30974 98d7b377e37d
child 30976 dc8bf00badd0
Related with issue 34453:Added missing catch block for the commitAndClose
src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java
--- a/src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java	Fri Dec 16 11:08:58 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java	Fri Dec 16 13:22:24 2016 +0100
@@ -154,15 +154,15 @@
       }
 
     } catch (Exception e) {
-      logger.logln(e.getMessage());
-      log.error(e.getMessage(), e);
-      throw new Exception(e.getMessage());
+      handleException(e);
     } finally {
       if ("S".equals(beatType)) {
         // Background scheduled beats require explicit commit
         try {
           OBContext.setAdminMode();
           OBDal.getInstance().commitAndClose();
+        } catch (Exception e) {
+          handleException(e);
         } finally {
           OBContext.restorePreviousMode();
         }
@@ -170,6 +170,12 @@
     }
   }
 
+  private void handleException(Exception e) throws Exception {
+    logger.logln(e.getMessage());
+    log.error(e.getMessage(), e);
+    throw new Exception(e.getMessage());
+  }
+
   private void updateHeartbeatStatus(String beatType) throws Exception {
 
     if (this.channel == Channel.SCHEDULED || DEFERRING_BEAT.equals(beatType)) {