private void maybeCloseFileChannel(@Nullable Throwable cause, boolean onError) {
        if (completionFuture.isDone()) {
            return;
        }

        if (cause == null) {
            completionFuture.complete(null);
        } else {
            if (!onError) {
                assert subscription != null;
                subscription.cancel();
            }
            completionFuture.completeExceptionally(cause);
        }

        if (fileChannel != null && fileChannel.isOpen()) {
            try {
                fileChannel.close();
            } catch (IOException e) {
                logger.warn("Failed to close '" + path + '\'', e);
            }
        }
    }
Asynchronously writes a {@code StreamMessage<HttpMessage>} to a {@link File}.
core/src/main/java/com/linecorp/armeria/common/stream/AsyncFileWriter.java