### Question:
ExceptionUtils { public static <T> CompletableFuture<T> callAndHandleClosedAsync(String componentName, boolean isClosed, CompletableRunnable<T> callable) { CompletableFuture<T> future = FutureUtils.createFuture(); if (isClosed) { future.completeExceptionally(new ObjectClosedException(componentName)); } else { callable.run(future); } return future; } private  ExceptionUtils(); static CompletableFuture<T> callAndHandleClosedAsync(String componentName,
                                                                    boolean isClosed,
                                                                    CompletableRunnable<T> callable); static IOException toIOException(Throwable cause);  }### Answer:
@Test public void testCallAndHandleClosedAsync() throws Exception { String componentName = "test-component"; CompletableFuture<Long> closedFuture = ExceptionUtils.callAndHandleClosedAsync( componentName, true, (future) -> { future.complete(10L); }); try { FutureUtils.result(closedFuture); fail("Should fail with object closed exception"); } catch (ObjectClosedException oce) { assertEquals(componentName + " is already closed.", oce.getMessage()); } CompletableFuture<Long> noneClosedFuture = ExceptionUtils.callAndHandleClosedAsync( componentName, false, (future) -> { future.complete(10L); }); assertEquals(10L, FutureUtils.result(noneClosedFuture).longValue()); }