Decreasing count when removing subscription listener

This commit is contained in:
Nelson R. Perez 2017-10-04 23:05:14 -05:00
parent 5e88c209e3
commit 6ac84f9a52

View file

@ -111,13 +111,15 @@ public class SubscriptionResponse {
* to be removed from the list. * to be removed from the list.
*/ */
public void removeSubscriptionListener(SubscriptionListener subscriptionListener){ public void removeSubscriptionListener(SubscriptionListener subscriptionListener){
if(listenerTypeCount.containsKey(subscriptionListener.getInterestObjectType())){
int currentCount = listenerTypeCount.get(subscriptionListener.getInterestObjectType()); int currentCount = listenerTypeCount.get(subscriptionListener.getInterestObjectType());
if(currentCount != 0){ if(currentCount > 0){
this.listenerTypeCount.put(subscriptionListener.getInterestObjectType(), currentCount); this.listenerTypeCount.put(subscriptionListener.getInterestObjectType(), currentCount - 1);
this.mListeners.remove(subscriptionListener);
}else{ }else{
System.out.println("Trying to remove subscription listener, but none is registered!"); System.out.println("Trying to remove subscription listener, but none is registered!");
} }
this.mListeners.remove(subscriptionListener); }
} }
/** /**