From b192f0919b2eedfbb1050ea2573617aa9614c5c1 Mon Sep 17 00:00:00 2001 From: sciPher80s <83955868+sciPher80s@users.noreply.github.com> Date: Mon, 3 Apr 2023 16:22:58 +0200 Subject: [PATCH] Fixed code logic in Notification.class reason for chaning == to != should be obvious at line 727 moreover, simply calling the remove( )function on subscriberList while passing subscriber is not functional; since each item of subscriberList will be tested for equality against the subscriber, and not the other way around; in other words, it's the subscriber's equal() function which is getting called, therefore it always returns false. alongside this fixture a small change is also applied on SubscriberObject's equal() method. --- src/docs/asciidoc/app-structure.asc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/docs/asciidoc/app-structure.asc b/src/docs/asciidoc/app-structure.asc index 01d6ad7..52ae2c9 100644 --- a/src/docs/asciidoc/app-structure.asc +++ b/src/docs/asciidoc/app-structure.asc @@ -724,9 +724,14 @@ public class Notifications { List subscriberList = instance.subscribers.get( event ); - if (subscriberList == null) { - subscriberList.remove( subscriber ); - } + if (subscriberList != null) { + for(SubscriberObject sObj : subscriberList) { + if(sObj.getSubscriber().equals(subscriber)) { + subscriberList.remove(sObj); + } + } + } + } static class SubscriberObject { @@ -755,7 +760,13 @@ public class Notifications { @Override public boolean equals(Object obj) { - return subscriber.equals(obj); + if(!(obj instanceof SubscriberObject)) { + return false; + } + else { + SubscriberObject otherSObj = (SubscriberObject) obj; + return Objects.equals(subscriber, otherSObj.subscriber); + } } } }