class CompositeListener implements ActionListener<Void> {

        private final List<ActionListener<Void>> listeners = new ArrayList<>();

        private final T request;

        private boolean isNotified;
        private Exception failure;

        CompositeListener(T request) {
            this.request = request;
        }

        CompositeListener addListener(ActionListener<Void> listener) {<FILL_FUNCTION_BODY>}

        private void onCompleted(Exception failure) {
            synchronized (this) {
                this.failure = failure;
                this.isNotified = true;
            }
            try {
                if (failure == null) {
                    ActionListener.onResponse(listeners, null);
                } else {
                    ActionListener.onFailure(listeners, failure);
                }
            } finally {
                requests.remove(request);
            }
        }

        @Override
        public void onResponse(final Void aVoid) {
            onCompleted(null);
        }

        @Override
        public void onFailure(Exception failure) {
            onCompleted(failure);
        }
    }

            synchronized (this) {
                if (this.isNotified == false) {
                    listeners.add(listener);
                    return listeners.size() == 1 ? this : null;
                }
            }
            if (failure != null) {
                listener.onFailure(failure);
            } else {
                listener.onResponse(null);
            }
            return null;
        
<no_super_class>