From: gu.martinm@gmail.com Date: Tue, 14 Oct 2014 17:21:46 +0000 (+0200) Subject: Spring DeadLocks retries X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=06c6817bee4c23f21c11a3a8b0d54a5cebccf03b;p=JavaForFun Spring DeadLocks retries --- diff --git a/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java b/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java index 6d1006f..1aa1915 100644 --- a/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java +++ b/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java @@ -72,7 +72,10 @@ public class DeadlockRetryAspect implements Ordered { } } while (count < maxTries); - throw new RuntimeException("DeadlockRetry failed, deadlock in all retry attempts.", lastException); + // Throwing exception because it matched or it contains (exception chaining) + // some of the exceptions from the list in the spring-config.xml file. + // The exception being thrown will depend on the API that you are using. + throw lastException; } @Override diff --git a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml index f8c6235..ff5e273 100644 --- a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml +++ b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml @@ -69,8 +69,13 @@ + com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException + org.springframework.dao.DeadlockLoserDataAccessException