Close the created URLClassLoader
when finishing the Ant task
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user