Buggy code:
@ Listener public class DistributedCacheManager < T extends OutgoingDistributableSessionData > implements SessionOwnershipSupport , org . jboss . as . clustering . web . DistributedCacheManager < T > { private static Map < SharedLocalYieldingClusterLockManager . LockResult , LockResult > results = DistributedCacheManager . lockResultMap ( ) ; private static Map < SharedLocalYieldingClusterLockManager . LockResult , LockResult > lockResultMap ( ) { } final SessionAttributeStorage < T > attributeStorage ; private final Random random = new Random ( System . currentTimeMillis ( ) ) ; private final LocalDistributableSessionManager manager ; private final SharedLocalYieldingClusterLockManager lockManager ; private final Cache < String , Map < Object , Object > > cache ; private final DistributedCacheManager . ForceSynchronousCacheInvoker invoker ; private final BatchingManager batchingManager ; private final boolean passivationEnabled ; private final Registry < String , Void > registry ; private final long lockTimeout ; public DistributedCacheManager ( LocalDistributableSessionManager manager , Cache < String , Map < Object , Object > > cache , Registry < String , Void > registry , SharedLocalYieldingClusterLockManager lockManager , SessionAttributeStorage < T > attributeStorage , BatchingManager batchingManager , CacheInvoker invoker ) { } @ Override public void start ( ) { } @ Override public void stop ( ) { } @ 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 ( final 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 ) { } @ Override public void removeSessionLocal ( String sessionId , String dataOwner ) { } @ Override public void evictSession ( final String sessionId ) { } @ Override public void evictSession ( String sessionId , String dataOwner ) { } @ Override public Map < String , String > getSessionIds ( ) { Map < String , String > result = new HashMap < String , String > ( ) ; <START_BUG> for ( String sessionId : this . cache . keySet ( ) ) { <END_BUG> result . put ( sessionId , null ) ; } return result ; } @ 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 ) { } private String createLockKey ( String sessionId ) { } @ Override public boolean isLocal ( String sessionId ) { } @ Override public String locate ( String sessionId ) { } @ CacheEntryRemoved public void removed ( CacheEntryRemovedEvent < String , Map < Object , Object > > event ) { } @ CacheEntryModified public void modified ( CacheEntryModifiedEvent < String , Map < Object , Object > > event ) { } @ CacheEntryActivated public void activated ( CacheEntryActivatedEvent < String , Map < Object , Object > > event ) { } private void trace ( String message , Object ... args ) { } private < R > R batch ( DistributedCacheManager < T > . Operation < R > operation ) { } private < R > R invoke ( CacheInvoker . Operation < String , Map < Object , Object > , R > operation ) { } abstract class Operation < R > implements CacheInvoker . Operation < String , 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:
for ( String sessionId : this . cache . getAdvancedCache ( ) . withFlags ( SKIP_LOCKING , SKIP_REMOTE_LOOKUP , SKIP_CACHE_LOAD ) . keySet ( ) ) {