Buggy code:
@ Listener public class DistributedCacheManager < T extends OutgoingDistributableSessionData , K extends SessionKey > implements SessionOwnershipSupport , org . jboss . as . clustering . web . DistributedCacheManager < T > { static String mask ( String sessionId ) { } private static final Random random = new Random ( ) ; private static Map < SharedLocalYieldingClusterLockManager . LockResult , LockResult > results = DistributedCacheManager . lockResultMap ( ) ; private static Map < SharedLocalYieldingClusterLockManager . LockResult , LockResult > lockResultMap ( ) { } final SessionAttributeStorage < T > attributeStorage ; private final LocalDistributableSessionManager manager ; private final SharedLocalYieldingClusterLockManager lockManager ; private final Cache < K , Map < Object , Object > > sessionCache ; private final DistributedCacheManager . ForceSynchronousCacheInvoker invoker ; private final BatchingManager batchingManager ; private final boolean passivationEnabled ; private final boolean requiresPurge ; private final DistributedCacheManager . JvmRouteHandler jvmRouteHandler ; private final SessionKeyFactory < K > keyFactory ; public DistributedCacheManager ( ServiceRegistry registry , LocalDistributableSessionManager manager , Cache < K , Map < Object , Object > > sessionCache , CacheSource jvmRouteCacheSource , SharedLocalYieldingClusterLockManager lockManager , SessionAttributeStorage < T > attributeStorage , BatchingManager batchingManager , SessionKeyFactory < K > keyFactory , CacheInvoker invoker ) { } @ Override public void start ( ) { } @ Override public void stop ( ) { } private void purge ( ) { } @ Override public BatchingManager getBatchingManager ( ) { } @ Override public void sessionCreated ( String sessionId ) { } @ Override public void storeSessionData ( final T sessionData ) { } @ Override public IncomingDistributableSessionData getSessionData ( String sessionId , boolean initialLoad ) { } @ Override public IncomingDistributableSessionData getSessionData ( final String sessionId , String dataOwner , boolean includeAttributes ) { } private IncomingDistributableSessionData getData ( String sessionId , final boolean includeAttributes ) { } @ Override public void removeSession ( final String sessionId ) { } @ Override public void removeSessionLocal ( final String sessionId ) { } private void removeSession ( final String sessionId , final boolean local ) { final K key = this . keyFactory . createKey ( sessionId ) ; DistributedCacheManager < T , K > . Operation < Map < Object , Object > > operation = new Operation < Map < Object , Object > > ( ) { @ Override public Map < Object , Object > invoke ( Cache < K , Map < Object , Object > > cache ) { <START_BUG> return cache . getAdvancedCache ( ) . withFlags ( ( local ? Flag . CACHE_MODE_LOCAL : Flag . SKIP_REMOTE_LOOKUP ) ) . remove ( key ) ; <END_BUG> } } ; this . invoker . invoke ( this . sessionCache , operation ) ; } @ Override public void removeSessionLocal ( String sessionId , String dataOwner ) { } @ Override public void evictSession ( String sessionId ) { } @ Override public void evictSession ( String sessionId , String dataOwner ) { } @ Override public Map < String , String > getSessionIds ( ) { } @ Override public boolean isPassivationEnabled ( ) { } @ Override public void setForceSynchronous ( boolean forceSynchronous ) { } @ Override public SessionOwnershipSupport getSessionOwnershipSupport ( ) { } @ Override public LockResult acquireSessionOwnership ( String sessionId , boolean newLock ) throws InterruptedException , TimeoutException { } @ Override public void relinquishSessionOwnership ( String sessionId , boolean remove ) { } @ Override public boolean isLocal ( String sessionId ) { } @ Override public String locate ( String sessionId ) { } @ CacheEntryRemoved public void removed ( CacheEntryRemovedEvent < K , Map < Object , Object > > event ) { } @ CacheEntryModified public void modified ( CacheEntryModifiedEvent < K , Map < Object , Object > > event ) { } @ CacheEntryActivated public void activated ( CacheEntryActivatedEvent < K , Map < Object , Object > > event ) { } private < R > R batch ( DistributedCacheManager < T , K > . Operation < R > operation ) { } @ Listener ( sync = false ) public static class JvmRouteHandler { static interface Operation < R > extends CacheInvoker . Operation < Address , String , R > { } private final ServiceRegistry registry ; private final LocalDistributableSessionManager manager ; private final CacheSource source ; JvmRouteHandler ( ServiceRegistry registry , CacheSource source , LocalDistributableSessionManager manager ) { } Cache < Address , String > getCache ( ) { } < R > R batch ( DistributedCacheManager . JvmRouteHandler . Operation < R > operation ) { } @ ViewChanged public void viewChanged ( final ViewChangedEvent event ) { } } abstract class Operation < R > implements CacheInvoker . Operation < K , Map < Object , Object > , R > { } static class ForceSynchronousCacheInvoker implements CacheInvoker { private static final ThreadLocal < Boolean > forceThreadSynchronous = new ThreadLocal < Boolean > ( ) { @ Override protected Boolean initialValue ( ) { } } ; private final CacheInvoker invoker ; private volatile boolean forceSynchronous = false ; ForceSynchronousCacheInvoker ( CacheInvoker invoker ) { } void setForceSynchronous ( boolean forceSynchronous ) { } void forceThreadSynchronous ( ) { } @ Override public < K , V , R > R invoke ( Cache < K , V > cache , Operation < K , V , R > operation ) { } } }

Fix:
return cache . getAdvancedCache ( ) . withFlags ( SKIP_CACHE_LOAD , ( local ? Flag . CACHE_MODE_LOCAL : Flag . SKIP_REMOTE_LOOKUP ) ) . remove ( key ) ;