Close the created URLClassLoader when finishing the Ant task

This commit is contained in:
Stefan Wolf
2016-07-25 14:08:04 +02:00
parent aafceb8d89
commit 23bee1cad1

View File

@ -3,6 +3,7 @@
*/
package net.sourceforge.pmd.ant.internal;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@ -266,10 +267,21 @@ public class PMDTaskImpl {
try {
doTask();
} finally {
tryClose(configuration.getClassLoader());
logManager.close();
}
}
private static void tryClose(ClassLoader classLoader) {
if (classLoader instanceof Closeable) {
try {
((Closeable) classLoader).close();
} catch (IOException ignore) {
// do nothing.
}
}
}
private void logRulesUsed(RuleSets rules) {
project.log("Using these rulesets: " + configuration.getRuleSets(), Project.MSG_VERBOSE);