diff options
author | 2017-08-08 11:27:33 +0000 | |
---|---|---|
committer | 2017-08-08 11:27:33 +0000 | |
commit | 96bca95f4610edfdabf1fddb981416235158312d (patch) | |
tree | 4eda53b3e021a1bd0c3275e33eac2c760f76cebc /integrity-audit/src/main/java | |
parent | 84d189267f246ba6a814d1a6d4ddbe164e65b058 (diff) | |
parent | 66221823c8cb131b8cea03c4d011ddd728608451 (diff) |
Merge "[POLICY-96] Resolved sonar blockers in im/ia."
Diffstat (limited to 'integrity-audit/src/main/java')
-rw-r--r-- | integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java | 52 |
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 |