@Override default CompletableFuture<V> get(K key, BiFunction<? super K, Executor, CompletableFuture<V>> mappingFunction) { return get(key, mappingFunction, /* recordStats */ true); }
@Override default CompletableFuture<V> get(@NonNull K key, @NonNull Function<? super K, ? extends V> mappingFunction) { requireNonNull(mappingFunction); return get(key, (k1, executor) -> CompletableFuture.supplyAsync( () -> mappingFunction.apply(key), executor)); }
@Override @SuppressWarnings("PMD.PreserveStackTrace") public V get(K key, Function<? super K, ? extends V> mappingFunction) { requireNonNull(mappingFunction); CompletableFuture<V> future = asyncCache().get(key, (k, executor) -> CompletableFuture.supplyAsync(() -> mappingFunction.apply(key), executor)); try { return future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else if (e.getCause() instanceof Error) { throw (Error) e.getCause(); } throw new CompletionException(e.getCause()); } catch (InterruptedException e) { throw new CompletionException(e); } }