vldpyatkov commented on code in PR #842:
URL: https://github.com/apache/ignite-3/pull/842#discussion_r911881287


##########
modules/core/src/main/java/org/apache/ignite/internal/manager/Producer.java:
##########
@@ -59,7 +66,19 @@ public void removeListener(T evt, EventListener<P> closure) {
      * @param cause   The exception that was a cause which a listener is 
removed.
      */
     public void removeListener(T evt, EventListener<P> closure, @Nullable 
IgniteInternalCheckedException cause) {
-        if (listeners.computeIfAbsent(evt, evtKey -> new 
ConcurrentLinkedQueue<>()).remove(closure)) {
+        removeListener(evt, closure, cause, true);
+    }
+
+    /**
+     * Removes a listener associated with the event.
+     *
+     * @param evt          Event.
+     * @param closure      Closure.
+     * @param cause        The exception that was a cause which a listener is 
removed.
+     * @param callOnRemove Whether to call {@link 
EventListener#remove(Throwable)} callback on the closure.
+     */
+    public void removeListener(T evt, EventListener<P> closure, @Nullable 
IgniteInternalCheckedException cause, boolean callOnRemove) {
+        if (listeners.computeIfAbsent(evt, evtKey -> new 
CopyOnWriteArrayList<>()).remove(closure) && callOnRemove) {
             closure.remove(cause == null ? new ListenerRemovedException() : 
cause.getCause() == null ? cause : cause.getCause());

Review Comment:
   `cause.getCause() == null ? cause : cause.getCause()`
   I was surprised that the logic is in the branch main.



##########
modules/core/src/main/java/org/apache/ignite/internal/manager/Producer.java:
##########
@@ -59,7 +66,19 @@ public void removeListener(T evt, EventListener<P> closure) {
      * @param cause   The exception that was a cause which a listener is 
removed.
      */
     public void removeListener(T evt, EventListener<P> closure, @Nullable 
IgniteInternalCheckedException cause) {
-        if (listeners.computeIfAbsent(evt, evtKey -> new 
ConcurrentLinkedQueue<>()).remove(closure)) {
+        removeListener(evt, closure, cause, true);
+    }
+
+    /**
+     * Removes a listener associated with the event.
+     *
+     * @param evt          Event.
+     * @param closure      Closure.
+     * @param cause        The exception that was a cause which a listener is 
removed.
+     * @param callOnRemove Whether to call {@link 
EventListener#remove(Throwable)} callback on the closure.

Review Comment:
   It is a suspicion parameter, because only a listener knows required to 
invoke it or not. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to