ExponentialBackOffRetryStrategy extends RetryStrategy { @Override public int getNextIntervalMillis(int retryCount) { int interval = config.getBaseIntervalMillis() * ((int) Math.pow(2.0, (double) retryCount)); if (interval > config.getMaxIntervalMillis()) { return config.getMaxIntervalMillis(); } return interval; } ExponentialBackOffRetryStrategy();  ExponentialBackOffRetryStrategy(Config config); @Override int getNextIntervalMillis(int retryCount); int getBaseIntervalMillis(); int getMaxIntervalMillis(); @Override String toString();  }
@Test void testGetNextIntervalMillis() { ExponentialBackOffRetryStrategy.Config config = new ExponentialBackOffRetryStrategy.Config(); config.setBaseIntervalMillis(400); config.setMaxIntervalMillis(30000); config.setMaxRetryCount(7); RetryStrategy strategy = new ExponentialBackOffRetryStrategy(config); assertEquals(400, strategy.getNextIntervalMillis(0)); assertEquals(800, strategy.getNextIntervalMillis(1)); assertEquals(1600, strategy.getNextIntervalMillis(2)); assertEquals(3200, strategy.getNextIntervalMillis(3)); assertEquals(25600, strategy.getNextIntervalMillis(6)); assertEquals(30000, strategy.getNextIntervalMillis(7)); assertFalse(strategy.isRetriedOver(7)); assertEquals(30000, strategy.getNextIntervalMillis(8)); assertTrue(strategy.isRetriedOver(8)); }