Buggy code:
public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { public static final int DEFAULT_CACHE_LIMIT = 1024 ; private volatile int cacheLimit = DefaultSubscriptionRegistry . DEFAULT_CACHE_LIMIT ; private PathMatcher pathMatcher = new AntPathMatcher ( ) ; private final DefaultSubscriptionRegistry . DestinationCache destinationCache = new DefaultSubscriptionRegistry . DestinationCache ( ) ; private final DefaultSubscriptionRegistry . SessionSubscriptionRegistry subscriptionRegistry = new DefaultSubscriptionRegistry . SessionSubscriptionRegistry ( ) ; public void setCacheLimit ( int cacheLimit ) { } public int getCacheLimit ( ) { } public void setPathMatcher ( PathMatcher pathMatcher ) { } public PathMatcher getPathMatcher ( ) { } @ Override protected void addSubscriptionInternal ( String sessionId , String subsId , String destination , Message < ? > message ) { } @ Override protected void removeSubscriptionInternal ( String sessionId , String subsId , Message < ? > message ) { DefaultSubscriptionRegistry . SessionSubscriptionInfo info = this . subscriptionRegistry . getSubscriptions ( sessionId ) ; if ( info != null ) { String destination = info . removeSubscription ( subsId ) ; <START_BUG> if ( ( destination != null ) && ( ( info . getSubscriptions ( destination ) ) == null ) ) { <END_BUG> this . destinationCache . updateAfterRemovedSubscription ( destination , sessionId , subsId ) ; } } } @ Override public void unregisterAllSubscriptions ( String sessionId ) { } @ Override protected MultiValueMap < String , String > findSubscriptionsInternal ( String destination , Message < ? > message ) { } @ Override public String toString ( ) { } private class DestinationCache { private final Map < String , MultiValueMap < String , String > > accessCache = new ConcurrentHashMap < String , MultiValueMap < String , String > > ( DefaultSubscriptionRegistry . DEFAULT_CACHE_LIMIT ) ; @ SuppressWarnings ( "serial" ) private final Map < String , MultiValueMap < String , String > > updateCache = new LinkedHashMap < String , MultiValueMap < String , String > > ( DefaultSubscriptionRegistry . DEFAULT_CACHE_LIMIT , 0.75F , true ) { @ Override protected boolean removeEldestEntry ( Map . Entry < String , MultiValueMap < String , String > > eldest ) { } } ; public MultiValueMap < String , String > getSubscriptions ( String destination ) { } public void addSubscriptions ( String destination , MultiValueMap < String , String > subscriptions ) { } public void updateAfterNewSubscription ( String destination , String sessionId , String subsId ) { } public void updateAfterRemovedSubscription ( String destination , String sessionId , String subsId ) { } public void updateAfterRemovedSession ( DefaultSubscriptionRegistry . SessionSubscriptionInfo info ) { } @ Override public String toString ( ) { } } private static class SessionSubscriptionRegistry { private final ConcurrentMap < String , DefaultSubscriptionRegistry . SessionSubscriptionInfo > sessions = new ConcurrentHashMap < String , DefaultSubscriptionRegistry . SessionSubscriptionInfo > ( ) ; public DefaultSubscriptionRegistry . SessionSubscriptionInfo getSubscriptions ( String sessionId ) { } public Collection < DefaultSubscriptionRegistry . SessionSubscriptionInfo > getAllSubscriptions ( ) { } public DefaultSubscriptionRegistry . SessionSubscriptionInfo addSubscription ( String sessionId , String subscriptionId , String destination ) { } public DefaultSubscriptionRegistry . SessionSubscriptionInfo removeSubscriptions ( String sessionId ) { } @ Override public String toString ( ) { } } private static class SessionSubscriptionInfo { private final String sessionId ; private final Map < String , Set < String > > subscriptions = new ConcurrentHashMap < String , Set < String > > ( 4 ) ; private final Object monitor = new Object ( ) ; public SessionSubscriptionInfo ( String sessionId ) { } public String getSessionId ( ) { } public Set < String > getDestinations ( ) { } public Set < String > getSubscriptions ( String destination ) { } public void addSubscription ( String destination , String subscriptionId ) { } public String removeSubscription ( String subscriptionId ) { } @ Override public String toString ( ) { } } }

Fix:
if ( destination != null ) {