public List receive()

in client/src/main/java/org/mvndaemon/mvnd/client/DaemonClientConnection.java [110:144]


    public List<Message> receive() throws ConnectException, StaleAddressException {
        while (true) {
            try {
                final Message m = queue.poll(maxKeepAliveMs, TimeUnit.MILLISECONDS);
                {
                    Exception e = exception.get();
                    if (e != null) {
                        throw e;
                    } else if (m == null) {
                        throw new IOException("No message received within " + maxKeepAliveMs
                                + "ms, daemon may have crashed. You may want to check its status using mvnd --status");
                    }
                }
                final List<Message> result = new ArrayList<>(4);
                result.add(m);
                queue.drainTo(result);
                Exception e = exception.get();
                if (e != null) {
                    throw e;
                }
                return result;
            } catch (Exception e) {
                DaemonDiagnostics diag = new DaemonDiagnostics(daemon.getId(), parameters);
                LOG.debug("Problem receiving message to the daemon. Performing 'on failure' operation...");
                if (!hasReceived && newDaemon) {
                    throw new ConnectException("Could not receive a message from the daemon.\n" + diag.describe(), e);
                } else if (staleAddressDetector.maybeStaleAddress(e)) {
                    throw new StaleAddressException(
                            "Could not receive a message from the daemon.\n" + diag.describe(), e);
                }
            } finally {
                hasReceived = true;
            }
        }
    }