From 4fd502de4b515d68e304ccecd986a7e35eaba154 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Thu, 9 Apr 2009 15:02:43 +0000 Subject: [PATCH] Retry exception detection unwraps NestedSQLException and UncategorizedSQLException git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13916 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RetryingTransactionHelper.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java index 42cf091efd..a702dba23a 100644 --- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java +++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java @@ -56,6 +56,8 @@ import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DeadlockLoserDataAccessException; import org.springframework.jdbc.UncategorizedSQLException; +import com.ibatis.common.jdbc.exception.NestedSQLException; + /** * A helper that runs a unit of work inside a UserTransaction, * transparently retrying the unit of work if the cause of @@ -451,11 +453,31 @@ public class RetryingTransactionHelper public static Throwable extractRetryCause(Throwable cause) { Throwable retryCause = ExceptionStackUtil.getCause(cause, RETRY_EXCEPTIONS); - if (retryCause == null || retryCause instanceof SQLGrammarException - && ((SQLGrammarException) retryCause).getErrorCode() != 3960) + + if (retryCause == null) { return null; } + else if (retryCause instanceof SQLGrammarException + && ((SQLGrammarException) retryCause).getErrorCode() != 3960) + { + return null; + } + else if (retryCause instanceof NestedSQLException || retryCause instanceof UncategorizedSQLException) + { + // The exception will have been caused by something else, so check that instead + if (retryCause.getCause() != null && retryCause.getCause() != retryCause) + { + // We dig further into this + cause = retryCause.getCause(); + // Recurse + return extractRetryCause(cause); + } + else + { + return null; + } + } // A simple match return retryCause; }