forked from phoedos/pmd
[core] Fix classloader closed issue when executing Ant task
Note: the problem (ClassNotFoundExceptions) only shows up with java8 - with java9 the classloader seems to be still usable, even after we closed it...
This commit is contained in:
@ -42,6 +42,7 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
|
|||||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||||
import net.sourceforge.pmd.renderers.AbstractRenderer;
|
import net.sourceforge.pmd.renderers.AbstractRenderer;
|
||||||
import net.sourceforge.pmd.renderers.Renderer;
|
import net.sourceforge.pmd.renderers.Renderer;
|
||||||
|
import net.sourceforge.pmd.util.ClasspathClassLoader;
|
||||||
import net.sourceforge.pmd.util.IOUtil;
|
import net.sourceforge.pmd.util.IOUtil;
|
||||||
import net.sourceforge.pmd.util.ResourceLoader;
|
import net.sourceforge.pmd.util.ResourceLoader;
|
||||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||||
@ -275,7 +276,11 @@ public class PMDTaskImpl {
|
|||||||
doTask();
|
doTask();
|
||||||
} finally {
|
} finally {
|
||||||
logManager.close();
|
logManager.close();
|
||||||
IOUtil.tryCloseClassLoader(configuration.getClassLoader());
|
// only close the classloader, if it is ours. Otherwise we end up with class not found
|
||||||
|
// exceptions
|
||||||
|
if (configuration.getClassLoader() instanceof ClasspathClassLoader) {
|
||||||
|
IOUtil.tryCloseClassLoader(configuration.getClassLoader());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user