Fixing muzzle?
MuzzlePlugin groovy checks that no threads are spawned because this holds the ClassLoader live. This was breaking with the caching change because the cache no longer uses the Cleaner service. This caused a problem because the Thread behind the cleaner is created lazily when the first task is created, but without the cache the creation was delayed. To solve this, I addressed the original cause of the leak. The newly created Thread automatically inherits the contextClassLoader of its parent, but that's unnecessary for a cleaner thread. So I changed the ThreadFactory for cleaner to explicitly null out the contextClassLoader. We should probably null out contextClassLoader in other thread factories and also reduce our use of contextClassLoaders in general, but that will left to another PR.
This commit is contained in:
parent
d50f901f39
commit
4c7a0ba7a7
|
@ -291,7 +291,10 @@ class MuzzlePlugin implements Plugin<Project> {
|
|||
doLast {
|
||||
final ClassLoader instrumentationCL = createInstrumentationClassloader(instrumentationProject, toolingProject)
|
||||
def ccl = Thread.currentThread().contextClassLoader
|
||||
def bogusLoader = new SecureClassLoader()
|
||||
def bogusLoader = new SecureClassLoader() {
|
||||
@Override
|
||||
String toString() { return "bogus" }
|
||||
}
|
||||
Thread.currentThread().contextClassLoader = bogusLoader
|
||||
final ClassLoader userCL = createClassLoaderForTask(instrumentationProject, bootstrapProject, taskName)
|
||||
try {
|
||||
|
|
|
@ -20,6 +20,7 @@ class Cleaner {
|
|||
final Thread thread = new Thread(r, "dd-cleaner");
|
||||
thread.setDaemon(true);
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
thread.setContextClassLoader(null);
|
||||
return thread;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue