code: public static Object delayedValue(CompletionStage<Void> stage, Object syncValue) {
        if (stage != null) {
           CompletableFuture<?> future = stage.toCompletableFuture();
           if (!future.isDone()) {
              return asyncValue(stage.thenApply(v -> syncValue));
           }
           if (future.isCompletedExceptionally()) {
              return asyncValue(stage);
           }
        }
        return syncValue;
     }
docs: Returns an InvocationStage if the provided CompletionStage is null, not completed or completed via exception.
  If these are not true the sync value is returned directly.
  @param stage wait for completion of this if not null
  @param syncValue sync value to return if stage is complete or as stage value
  @return invocation stage or sync value