Skip to content

Commit

Permalink
Attempt to fix closure-related test failures in PostgreSQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Dec 16, 2014
1 parent f64d37d commit 99c370f
Showing 1 changed file with 17 additions and 7 deletions.
Expand Up @@ -1097,18 +1097,28 @@ private void handleConstraintViolationException(Session session, ConstraintViola

SQLException sqlException = findSqlException(ex);
if (sqlException != null) {
LOGGER.debug("ConstraintViolationException = {}, embedded SQL exception = {}", ex, sqlException.getNextException());
SQLException nextException = sqlException.getNextException();
LOGGER.debug("ConstraintViolationException = {}; SQL exception = {}; embedded SQL exception = {}", new Object[] {ex, sqlException, nextException});
String[] ok = new String[] {
"duplicate key value violates unique constraint \"m_org_closure_pkey\"",
"duplicate key value violates unique constraint \"m_reference_pkey\""
};
String msg1;
if (sqlException.getMessage() != null) {
String msg = sqlException.getMessage();
for (int i = 0; i < ok.length; i++) {
if (msg.contains(ok[i])) {
rollbackTransaction(session, ex, result, false);
throw new SerializationRelatedException(ex);
}
msg1 = sqlException.getMessage();
} else {
msg1 = "";
}
String msg2;
if (nextException != null && nextException.getMessage() != null) {
msg2 = nextException.getMessage();
} else {
msg2 = "";
}
for (int i = 0; i < ok.length; i++) {
if (msg1.contains(ok[i]) || msg2.contains(ok[i])) {
rollbackTransaction(session, ex, result, false);
throw new SerializationRelatedException(ex);
}
}
}
Expand Down

0 comments on commit 99c370f

Please sign in to comment.