@Test
public void testReloadFailedGets() throws Exception {

    AsyncLoadingCache<String, Integer> cachedResult = new AsyncLoadingCache<>(250);
    AtomicInteger counter1 = new AtomicInteger();
    AtomicInteger counter2 = new AtomicInteger();
    for (int i = 1; i <= 3; i++) {
        assertThat(cachedResult.orElseGet("k1", getSupplier(234, counter1, false)).join(), is(234));
        assertThat("we do not call the supplier while the cache is valid", counter1.get(), is(1));
        assertThrows(CompletionException.class, () -> cachedResult.orElseGet("k2", getSupplier(987, counter2, true)).join());
        assertThat("we retry the supplier after a failure", counter2.get(), is(i));
    }
}