Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] ConcurrentModificationException

Hi Luca,
a ConcurrentModificationException on a HashMap is usually thrown when an Iterator is being used and the map gets modified, either by another thread or by the same thread. If you obtain an iterator from the cache, then clean it, then call iterator.next(), you'll get the exception.

Since AspectJ does not do any thread magic, I don't think this is an AspectJ related issue.

Anyway, please note that you are resetting the cache ALSO everytime doInBackground is called, maybe it is the correct and expected behavior, but is different from what you state in the mail, could that be the error?

Simone

Il giorno 05/dic/08, alle ore 12:27, Luca Ferrari <fluca1978@xxxxxxxxxxx> ha scritto:

Hi all,
I got a ConcurrentModificationException using an aspect but I don't understand why. This is the situation: I've got a LazyLoadingCache object (singleton) that thru a few synchronized methods allows the insertion/deletion of entries in the cache. The cache internally uses a HashMap to store the information.

Then I've got the following pointcut:

pointcut emptyLazyLoadingCache() :
(execution( public static  List
g2.database.mapping.*.loadAll(ProgressObserver) throws DatabaseException )
||
execution( protected ListTableModel
g2.gui.workers.TableSwingWorker.doInBackground() throws Exception )
)
&&
(! cflow(adviceexecution()) )
;

that catches when a "loadAll" action is issued. The aim is to reset the cache for a complete reload of the data. To achieve this, the following advice is
defined:

before() : emptyLazyLoadingCache(){

   Class ownerClass = ...
      ....
   // empty the cache
   int refactor = this.llCache.emptyCacheForClass( ownerClass );
   }

where llCache is the singleton instance of the cache, and the
emptyCacheForClas method is a synchronized method that performs a remove on the hashmap. However, I got the above exception, and I've checked printing the
thread ids and each time the thread is always the same (that is a
SwingWorker). Any idea about where and how to investigate?


Thanks,
Luca
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top