log.trace("End nextTask(FINISHED), task="+task);
return;
}
}
ThreadTask threadTask = taskList.remove(0);
ClassLoadingTask loadTask = threadTask.getLoadTask();
if (trace)
log.trace("Begin nextTask(" + taskList.size() + "), loadTask=" + loadTask);
try
{
Thread taskThread = threadTask.getThread();
if (taskThread == null)
{
/* This is a task that has been reassigned back to the original
requesting thread ClassLoadingTask, so a new ThreadTask must
be scheduled.
*/
if (trace)
log.trace("Rescheduling threadTask=" + threadTask);
scheduleTask(loadTask, threadTask.getLoader(), true);
}
else
{
if (trace)
log.trace("Running threadTask=" + threadTask);
threadTask.run();
}
}
catch (Throwable e)
{
if (trace)
log.trace("Run failed with exception", e);
boolean retry = e instanceof ClassCircularityError || e.getClass().equals(LinkageError.class);
if (retry && loadTask.incrementNumCCE() < MAX_CCE)
{
/* Reschedule this task after all existing tasks to allow the
current load tasks which are conflicting to complete.
*/
try
{
// Reschedule and update the loadTask.threadTaskCount
scheduleTask(loadTask, threadTask.getLoader(), true);
}
catch (Throwable ex)
{
loadTask.setLoadError(ex);
log.warn("Failed to reschedule task after CCE", ex);
}
if (trace)
log.trace("Post CCE state, loadTask=" + loadTask);
}
else
{
loadTask.setLoadError(e);
}
}
finally
{
// Release any lock on the classloader
if (threadTask.isReleaseInNextTask())
threadTask.getClassLoader().unlock(false);
}
// If the ThreadTasks are complete mark the ClassLoadingTask finished
if (loadTask.getThreadTaskCount() == 0)
{