@Override
    public long nextBackOffMillis() {
        // Make sure we have not gone over the maximum elapsed time.
        if (getElapsedTimeMillis() > maxElapsedTimeMillis) {
            return maxElapsedTimeMillis;
        }
        int randomizedInterval =
                getRandomValueFromInterval(randomizationFactor, Math.random(), currentIntervalMillis);
        incrementCurrentInterval();
        return randomizedInterval;
    }
@Test
    public void testBackOffOverflow() {
        int testInitialInterval = Integer.MAX_VALUE / 2;
        double testMultiplier = 2.1;
        int testMaxInterval = Integer.MAX_VALUE;
        ExponentialBackOff backOffPolicy =
                new ExponentialBackOff.Builder()
                        .setInitialIntervalMillis(testInitialInterval)
                        .setMultiplier(testMultiplier)
                        .setMaxIntervalMillis(testMaxInterval)
                        .build();
        backOffPolicy.nextBackOffMillis();
        // Assert that when an overflow is possible the current interval is set to the max interval.
        assertEquals(testMaxInterval, backOffPolicy.getCurrentIntervalMillis());
    }