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
protected final ActionListener<DelegateResponse> delegate;
        protected Delegating(ActionListener<DelegateResponse> delegate) {
            this.delegate = delegate;
        }
        @Override
        public void onFailure(Exception e) {
            try {
                delegate.onFailure(e);
            } catch (RuntimeException ex) {
                if (ex != e) {
                    ex.addSuppressed(e);
                }
                assert false : new AssertionError("listener.onFailure failed", ex);
                throw ex;
            }
        }
        @Override
        public String toString() {
            return getClass().getName() + "/" + delegate;
        }
    }
    final class MappedActionListener<Response, MappedResponse> extends Delegating<Response, MappedResponse> {