default CompletableFuture<?> whenComplete() {
        if (this instanceof StreamMessage) {
            return ((StreamMessage<?>) this).whenComplete();
        }

        if (this instanceof CompletionStage) {
            return ((CompletionStage<?>) this).toCompletableFuture();
        }

        throw new IllegalStateException(
                "response must be a " + StreamMessage.class.getSimpleName() + " or a " +
                CompletionStage.class.getSimpleName() + ": " + getClass().getName());
    }
Returns a {@link CompletableFuture} which completes when
1) the response stream has been closed (the {@link StreamMessage} has been completed) or
2) the result value is set (the {@link CompletionStage} has completed.)
core/src/main/java/com/linecorp/armeria/common/Response.java