summaryrefslogtreecommitdiffstats
path: root/integrity-audit
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-audit')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java52
1 files changed, 38 insertions, 14 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
index 64c01931..0db43bbc 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
@@ -709,21 +709,45 @@ public class DbDAO {
* two or three milliseconds)
*/
} catch (LockTimeoutException e) {
- em.getTransaction().rollback();
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage();
- logger.error(msg + e);
- System.out.println(new Date());
- e.printStackTrace();
- throw new DbDaoTransactionException(msg, e);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage();
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
+ else {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
} catch (Exception e) {
- em.getTransaction().rollback();
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught Exception, message=" + e.getMessage();
- logger.error(msg + e);
- System.out.println(new Date());
- e.printStackTrace();
- throw new DbDaoTransactionException(msg, e);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught Exception, message=" + e.getMessage();
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
+ else {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
}
} // end synchronized block