Skip to main content

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

On Friday 5 December 2008 12:58:53 Simone Gianni wrote:
> 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.
>

Thanks, I thought it was only thrown by different threads. Now I solved the 
problem.

> 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?

The fact is that I've got a WorkerThread that, thru reflection, invokes the 
loadAll method on a few classes. So I've got two entry points for the load all 
method call and execution: a direct call and an invocation thru reflection in 
the worker thread. That's why I'm catching both situations.

Since we are talking about that....I've got to extract the target class (i.e., 
the class on which the static method is invoked) in the following way:

  before() : emptyLazyLoadingCache(){
	
	// from where I'm calling loadALl?
	Class declaringClass = 
thisJoinPointStaticPart.getSignature().getDeclaringType();
	Class ownerClass = null;
	if( declaringClass.getName().equals("g2.gui.workers.TableSwingWorker") ){
	    // obtain the loading class
	    TableSwingWorker worker = (TableSwingWorker) thisJoinPoint.getThis();
	    ownerClass = worker.getLoadingClass();
	}
	else{
	    ownerClass = thisJoinPointStaticPart.getSignature().getDeclaringType();
	}
	

}


that is not very elegant, is there another smarter way to pass the class 
context to the advice in both cases?

Thanks,
Luca




Back to the top