https://github.com/elastic/elasticsearch/blob/099fb84cfcf87be6689c3516674f45438bafa767/server/src/main/java/org/elasticsearch/action/ActionListener.java#L420-L432

Rather than keeping hold of the `delegate` and using an `AtomicBoolean` to track the completion, we could use an `AtomicReference` and drop the whole listener on completion, which might free up heap in some fail-fast cases.
server/src/main/java/org/elasticsearch/action/ActionListener.java
/**
     * Handle action response. This response may constitute a failure or a
     * success but it is up to the listener to make that decision.
     */
    void onResponse(Response response);
    /**
     * A failure caused by an exception at some phase of the task.
     */
    void onFailure(Exception e);
    @SuppressWarnings("rawtypes")
    ActionListener NOOP = new ActionListener() {
        @Override
        public void onResponse(Object o) {
        }
        @Override
        public void onFailure(Exception e) {
        }