@Override @SuppressWarnings("unchecked") public CompletableFuture<Void> dispatchAsync(String dispatchId, Runnable task) { try { return (CompletableFuture<Void>) cachedDispatchQueues.compute( dispatchId, (k, queue) -> { CompletableFuture<Void> voidCompletableFuture = (queue == null) ? CompletableFuture.runAsync(task) : ((CompletableFuture<Void>) queue).thenRunAsync(task); return voidCompletableFuture; }); } catch (Throwable t) { log.warn( "Exception thrown when calling dispatchAngGetFuture for dispatchId[{}]", dispatchId, t); throw t; } }