• Bug
  • Status: Closed
  • Resolution: Fixed
  • drb
  • Reporter: sourceforgetracker
  • September 21, 2009
  • 0
  • Watchers: 0
  • September 22, 2009
  • September 22, 2009

Description

I get this intermittently when doing a Cache#flush():

Exception in thread “main” java.util.ConcurrentModificationException at java.util.ArrayList.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source) at java.util.Collections$SynchronizedCollection.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at net.sf.ehcache.store.DiskStore.writeIndex(DiskStore.java:816) at net.sf.ehcache.store.DiskStore.flush(DiskStore.java:573) at net.sf.ehcache.Cache.flush(Cache.java:1509) at com.wiley.wispers.resolvedoi.EHCacheImpl.main(EHCacheImpl.java:655)

What seems to be happening is that the expiry thread is kicking in during the DiskStore#writeIndex() call, and, since #writeIndex() doesn’t synchronize on the spoolLock, while DiskStore#expireElements() does, this causes a ConcurrentModificationException. It looks like DiskStore#writeIndex() needs some additional synchronization.

Work-around: catch exception and retry Cache#flush() operation (presuming the expiry thread runs less frequently than the time taken to persist the cache!).

Sourceforge Ticket ID: 2008055 - Opened By: ellispritchard - 1 Jul 2008 17:36 UTC

Comments

Fiona OShea 2009-09-22

Re-opening so that I can properly close out these issues and have correct Resolution status in Jira