DefaultRetryCommandFactory implements RetryCommandFactory<V> { @Override public void destroy() throws Exception { destroy.set(true); } DefaultRetryCommandFactory();  DefaultRetryCommandFactory(int retryTimes, RetryPolicy retryPolicy, ScheduledExecutorService scheduled);  DefaultRetryCommandFactory(RetryPolicy retryPolicy, int retryTimeoutMilli, ScheduledExecutorService scheduled); static RetryCommandFactory noRetryFactory(); static RetryCommandFactory retryForever(ScheduledExecutorService scheduled, int retryDelayMilli); static RetryCommandFactory retryNTimes(ScheduledExecutorService scheduled, int retryTimes, int retryDelayMilli); @Override Command<V> createRetryCommand(Command<V> command); @Override void destroy();  }
@Test public void testDestroy() throws Exception { String msg = randomString(); SettableFuture<Boolean> future = SettableFuture.create(); retryCommandFactory = DefaultRetryCommandFactory.retryForever(scheduled, 1); Command<String> retryCommand = retryCommandFactory.createRetryCommand(new TestCommand(new Exception(msg), sleepMilli)); retryCommand.execute(executors).addListener(new CommandFutureListener<String>() { @Override public void operationComplete(CommandFuture<String> commandFuture) throws Exception { logger.info("[operationComplete]"); future.set(true); } }); logger.info("[destroy retryCommandFactory]"); retryCommandFactory.destroy(); Assert.assertTrue(future.get(200, TimeUnit.MILLISECONDS)); }