### Question:
Backoff { public static Stream<Long> exponentialJittered(long startMs, long maxMs) { final long startNanos = TimeUnit.NANOSECONDS.convert(startMs, TimeUnit.MILLISECONDS); final long maxNanos = TimeUnit.NANOSECONDS.convert(maxMs, TimeUnit.MILLISECONDS); final AtomicLong attempts = new AtomicLong(1); return Stream.iterate(startMs, lastMs -> { long shift = Math.min(attempts.get(), MaxBitShift); long maxBackoffNanos = Math.min(maxNanos, startNanos * (1L << shift)); long randomMs = TimeUnit.MILLISECONDS.convert( ThreadLocalRandom.current().nextLong(startNanos, maxBackoffNanos), TimeUnit.NANOSECONDS); attempts.incrementAndGet(); return randomMs; }); }  static Stream<Long> constant(long startMs); static Stream<Long> exponential(long startMs,
                                           int multiplier,
                                           long maxMs); static Stream<Long> exponentialJittered(long startMs,
                                                   long maxMs); static Stream<Long> decorrelatedJittered(long startMs,
                                                    long maxMs); static Stream<Long> equalJittered(long startMs,
                                             long maxMs); static final Policy DEFAULT; }### Answer:
@Test public void testExponentialJittered() throws Exception { Stream<Long> backoffs = Backoff.exponentialJittered(5, 120).limit(10); Stream<Long> maxBackoffs = Stream.of(5L, 10L, 20L, 40L, 80L, 120L, 120L, 120L, 120L, 120L); StreamUtil.<Long, Long, Void>zip(backoffs, maxBackoffs, (expected, actual) -> { assertTrue(expected <= actual); return null; }); }