@Test public void testRemoveSubscription_client_session_null() throws Exception { assertFalse(subscriptionManager.removeSubscription(null, SUBSCRIPTION_ID)); }
public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { return false; } Subscription removedSubscription = clientSubscriptions.remove(subscriptionId); if (clientSubscriptions.isEmpty()) { clientsSubscriptions.remove(clientSessionToken); } if (removedSubscription != null) { Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(removedSubscription.getTopic()); if (topicSubscriptions != null) { topicSubscriptions.remove(removedSubscription); if (topicSubscriptions.isEmpty()) { topicsSubscriptions.remove(removedSubscription.getTopic()); } } } return true; }
SubscriptionManager { public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { return false; } Subscription removedSubscription = clientSubscriptions.remove(subscriptionId); if (clientSubscriptions.isEmpty()) { clientsSubscriptions.remove(clientSessionToken); } if (removedSubscription != null) { Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(removedSubscription.getTopic()); if (topicSubscriptions != null) { topicSubscriptions.remove(removedSubscription); if (topicSubscriptions.isEmpty()) { topicsSubscriptions.remove(removedSubscription.getTopic()); } } } return true; } }
SubscriptionManager { public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { return false; } Subscription removedSubscription = clientSubscriptions.remove(subscriptionId); if (clientSubscriptions.isEmpty()) { clientsSubscriptions.remove(clientSessionToken); } if (removedSubscription != null) { Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(removedSubscription.getTopic()); if (topicSubscriptions != null) { topicSubscriptions.remove(removedSubscription); if (topicSubscriptions.isEmpty()) { topicsSubscriptions.remove(removedSubscription.getTopic()); } } } return true; } private  SubscriptionManager(); }
SubscriptionManager { public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { return false; } Subscription removedSubscription = clientSubscriptions.remove(subscriptionId); if (clientSubscriptions.isEmpty()) { clientsSubscriptions.remove(clientSessionToken); } if (removedSubscription != null) { Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(removedSubscription.getTopic()); if (topicSubscriptions != null) { topicSubscriptions.remove(removedSubscription); if (topicSubscriptions.isEmpty()) { topicsSubscriptions.remove(removedSubscription.getTopic()); } } } return true; } private  SubscriptionManager(); static SubscriptionManager getInstance(); synchronized Set<Subscription> retrieveSubscriptionsByTopic(String topic); synchronized Map<Long, Subscription> retrieveSubscriptionsByToken(String clientSessionToken); synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId,
			String topic, Ack ackMode); synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId); synchronized boolean removeSubscriptions(String clientSessionToken); }
SubscriptionManager { public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { return false; } Subscription removedSubscription = clientSubscriptions.remove(subscriptionId); if (clientSubscriptions.isEmpty()) { clientsSubscriptions.remove(clientSessionToken); } if (removedSubscription != null) { Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(removedSubscription.getTopic()); if (topicSubscriptions != null) { topicSubscriptions.remove(removedSubscription); if (topicSubscriptions.isEmpty()) { topicsSubscriptions.remove(removedSubscription.getTopic()); } } } return true; } private  SubscriptionManager(); static SubscriptionManager getInstance(); synchronized Set<Subscription> retrieveSubscriptionsByTopic(String topic); synchronized Map<Long, Subscription> retrieveSubscriptionsByToken(String clientSessionToken); synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId,
			String topic, Ack ackMode); synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId); synchronized boolean removeSubscriptions(String clientSessionToken);  }