protected CompletableFuture<Boolean> processRequest(ClickHouseConfig config, ClickHouseInputStream in,
            ClickHouseOutputStream out) throws IOException {
        final long timeout = config.getSocketTimeout();

        log.trace("About to set request: [in=%s, out=%s, timeout=%d]", in, out, timeout);
        long startTime = 0L;
        final SocketRequest req = new SocketRequest(config, in, out);
        while (!request.compareAndSet(null, req)) {
            if (timeout <= 0L) {
                // busy wait
            } else if (startTime == 0L) {
                startTime = System.currentTimeMillis();
            } else if (System.currentTimeMillis() - startTime > timeout) {
                throw new SocketTimeoutException(ClickHouseUtils.format(ERROR_WRITE_TIMEOUT, timeout));
            }
        }
        // log.trace("Request changed to: [%s]", req);

        setInterestOp(SelectionKey.OP_WRITE);

        return ClickHouseClient.submit(() -> {
            while (req != request.get() || !req.isDone()) {
                // busy wait
            }
            return req.hasError();
        });
    }
Reads raw request from the input stream.
clickhouse-client/src/main/java/com/clickhouse/client/AbstractSocketClient.java