diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index 2433fd0b6..ebeaebc4b 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -118,26 +118,28 @@ public class CommandAsyncService implements CommandAsyncExecutor { @Override public V get(RFuture future) { - final CountDownLatch l = new CountDownLatch(1); - future.addListener(new FutureListener() { - @Override - public void operationComplete(Future future) throws Exception { - l.countDown(); + if (!future.isDone()) { + final CountDownLatch l = new CountDownLatch(1); + future.addListener(new FutureListener() { + @Override + public void operationComplete(Future future) throws Exception { + l.countDown(); + } + }); + + boolean interrupted = false; + while (!future.isDone()) { + try { + l.await(); + } catch (InterruptedException e) { + interrupted = true; + } } - }); - - boolean interrupted = false; - while (!future.isDone()) { - try { - l.await(); - } catch (InterruptedException e) { - interrupted = true; + + if (interrupted) { + Thread.currentThread().interrupt(); } } - - if (interrupted) { - Thread.currentThread().interrupt(); - } // commented out due to blocking issues up to 200 ms per minute for each thread // future.awaitUninterruptibly();