From a24f24fc6dffaf100d8f3f5a34d41d3413209c15 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 16 Jun 2020 12:31:36 -0400 Subject: [PATCH] More retry for TransactionTimedOutException Related to https://github.com/spring-projects/spring-integration/issues/3307 --- .../integration/jdbc/lock/JdbcLockRegistry.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java index 5277e0b8fbe..7c4636557eb 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.integration.support.locks.ExpirableLockRegistry; import org.springframework.integration.support.locks.LockRegistry; import org.springframework.integration.util.UUIDConverter; +import org.springframework.transaction.TransactionTimedOutException; import org.springframework.util.Assert; /** @@ -46,6 +47,8 @@ * @author Vedran Pavic * @author Kai Zimmermann * @author Bartosz Rempuszewski + * @author Gary Russell + * @author Alexandre Strubel * * @since 4.3 */ @@ -164,6 +167,9 @@ public void lockInterruptibly() throws InterruptedException { catch (TransientDataAccessException e) { // try again } + catch (TransactionTimedOutException e) { + // try again + } catch (InterruptedException ie) { this.delegate.unlock(); Thread.currentThread().interrupt(); @@ -208,6 +214,9 @@ public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { catch (TransientDataAccessException e) { // try again } + catch (TransactionTimedOutException e) { + // try again + } catch (Exception e) { this.delegate.unlock(); rethrowAsLockException(e);