protected static void handleWriteResult(CompletableFuture<?> future, long timeout, Runnable postCloseAction)
            throws UncheckedIOException {
        try {
            if (future != null) {
                future.get(timeout, TimeUnit.MILLISECONDS);
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new UncheckedIOException(new IOException("Writing was interrupted", e));
        } catch (TimeoutException e) {
            throw new UncheckedIOException(
                    new IOException(ClickHouseUtils.format("Writing timed out after %d milliseconds", timeout), e));
        } catch (ExecutionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof IOException) {
                throw new UncheckedIOException((IOException) cause);
            } else if (cause instanceof UncheckedIOException) {
                throw (UncheckedIOException) cause;
            } else {
                throw new UncheckedIOException(new IOException("Writing failed", cause));
            }
        } finally {
            if (postCloseAction != null) {
                postCloseAction.run();
            }
        }
    }
Handles async write result.

@param future          async write result
@param timeout         timeout in milliseconds
@param postCloseAction post close aciton, could be null
@throws UncheckedIOException when writing failed
clickhouse-data/src/main/java/com/clickhouse/data/ClickHousePipedOutputStream.java