After inspecting this issue, I came to the following conclusion:
- The FileCacheScanner#run() method has a problematic synchronization issue.
// line 402-407 of FileCache.java
Collection values = Collections.synchronizedCollection(FileCache.this.cache.values());
for (Iterator it = values.iterator(); it.hasNext(); )
FileCacheEntry entry = (FileCacheEntry) it.next();
It synchronizes the 'values', entry collection of the cache object, but it cannot block entry additions of other threads because it does not synchronize the cache object.
If the entry collection is modified, then the next() will sometimes throw a ConcurrentModificationException.
By the way, I think we'd better defer fixing this issue to the 2.2 release because of the following reasons:
- The problem may not be a critical problem in a production system because psml pages don't seem to be frequently added.
- There's no critical problem even though this exception is logged. It will just scan again later.
- I don't think it's a good idea that we improve this FileCache class. IMO, we'd better use good caching framework library such EhCache. This change could be bigger than we expect, so let's defer this issue.