ClassLoaderManager
This is a replacement/port of LoadMgr3.
I originally tried to rewrite this as something intelligble but couldn't get it to
work.
So I just copied it and simplified it, e.g. only the Domain deals with the
ClassLoadingTasks now and the ClassLoaderManger doesn't deal with domains
it deals with [Class]Loaders.
After I did this it still didn't work :-)
It was only when I implemented timeouts on the two most important waits
| boolean interrupted = thread.interrupted();
|
| int waits = 0;
|
| try
| {
| while (true)
| {
| try
| {
| if (lock.tryLock(0, TimeUnit.MICROSECONDS) == false)
| {
| // REVIEW: If we've been spinning for more than a minute then
there is probably something wrong?
| if (waits++ == 6)
| throw new IllegalStateException("Waiting too long to get the
classloader lock: " + this);
| // Wait 10 seconds
| if (trace)
| log.trace(this + " waiting for lock " + thread);
| this.wait(10000);
| }
| else
| {
| if (trace)
| log.trace(this + " aquiredLock " + thread + "
holding=" + lock.getHoldCount());
| break;
| }
| }
| catch (InterruptedException ignored)
| {
| }
| }
| }
| finally
| {
| if (interrupted)
| thread.interrupt();
| }
|
that I figured out what was going on.
It started working with the timeouts, but only after a 10 second pause (co-incidence? :-)
A missed notification perhaps?
The answer was there is something subtle in the way the ClassLoaderManager
and the ClassLoader hand off control to each other.
Normally you release locks in the reverse order you aquire them.
Not here. Once I modified the lock release and notifyAll() to match the old
LoadMgr3 code it started working. :-)
Very Voodoo!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041351#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...