@Test
public void testSupplierExceptionDoesNotCacheValue() {

    AsyncLoadingCache<Integer, Boolean> cachedResult = new AsyncLoadingCache<>(30000);
    final AtomicInteger counter = new AtomicInteger();
    final Supplier<CompletableFuture<Boolean>> supplier = () -> {
        counter.incrementAndGet();
        throw new RecordCoreException("this is only a test");
    };
    for (int i = 0; i < 10; i++) {
        try {
            cachedResult.orElseGet(1, supplier).join();
            fail("should throw RecordCoreException");
        } catch (RecordCoreException e) {
            assertThat(e.getMessage(), containsString("failed getting value"));
            assertThat(e.getCause().getMessage(), containsString("this is only a test"));
        }
    }
    assertThat("we have to call the supplier each time", counter.get(), is(10));
}