@Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { log.info("Successful {}", action); setChannel(future.channel()); return; } final long delay = policy.delay(attempt); log.warn("Failed {} (attempt: {}), retrying in {}s: {}", action, attempt + 1, TimeUnit.SECONDS.convert(delay, TimeUnit.MILLISECONDS), future.cause().getMessage()); timer.newTimeout(new TimerTask() { @Override public void run(Timeout timeout) throws Exception { if (stopped.get()) { return; } trySetup(attempt + 1); } }, delay, TimeUnit.MILLISECONDS); } });