From 25e1b731bf5721ea3f44cf41b0f10e8efe40e85b Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 7 May 2018 14:09:36 -0400 Subject: [PATCH] Fix LockRegLeaderInitiator for interrupted Thread https://build.spring.io/browse/INT-MASTER-1024 When the Lettuce Redis client catches an `InterruptedException`, it is wrapped to the `RedisCommandInterruptedException`, therefore when we catch an exception on our code level it is not an `InterruptedException` anymore and we can't proceed in the loop because the tread is `interrupted` already. * Check the `interrupted` alongside with the `InterruptedException` to restart a loop from a fresh thread. **Cherry-pick to 5.0.x** (cherry picked from commit fc47952) --- .../integration/support/leader/LockRegistryLeaderInitiator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java b/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java index 609b161c65..0b068f0d44 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/leader/LockRegistryLeaderInitiator.java @@ -398,7 +398,7 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe } } - if (e instanceof InterruptedException) { + if (e instanceof InterruptedException || Thread.currentThread().isInterrupted()) { Thread.currentThread().interrupt(); if (isRunning()) { logger.warn("Restarting LeaderSelector because of error.", e);