In the CachedSubEntries::getSubEntries method the code does this:
if (SMSEntry.cacheSMSEntries)
{ // Add to cache Set answer = new LinkedHashSet(subEntries); ssoTokenToSubEntries.put(tokenID, answer); subEntries = answer; lastUpdated = System.currentTimeMillis(); }so we actually return a reference to the cache. If we change anything in this set, we will effect the cache entry. Another hit to the cache will return the same object which could of been corrupted. We should return a copy so the cache entry is not effected.
so we should do something like this:
if (SMSEntry.cacheSMSEntries)
{ // Add to cache Set answer = new LinkedHashSet(subEntries); ssoTokenToSubEntries.put(tokenID, answer); subEntries = new LinkedHashSet(answer); lastUpdated = System.currentTimeMillis(); }