Merge branch 'fault-tolerant' of https://github.com/rsalvador/pmd

This commit is contained in:
Romain PELISSE
2012-11-28 15:30:49 +01:00
2 changed files with 18 additions and 12 deletions

View File

@ -8,6 +8,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.pmd.benchmark.Benchmark;
import net.sourceforge.pmd.benchmark.Benchmarker;
@ -29,6 +31,8 @@ import net.sourceforge.pmd.util.filter.Filters;
//FUTURE Implement Cloneable and clone()
public class RuleSet {
private static final Logger LOG = Logger.getLogger(RuleSet.class.getName());
private List<Rule> rules = new ArrayList<Rule>();
private String fileName;
private String name = "";
@ -207,12 +211,18 @@ public class RuleSet {
public void apply(List<? extends Node> acuList, RuleContext ctx) {
long start = System.nanoTime();
for (Rule rule : rules) {
if (!rule.usesRuleChain() && applies(rule, ctx.getLanguageVersion())) {
rule.apply(acuList, ctx);
long end = System.nanoTime();
Benchmarker.mark(Benchmark.Rule, rule.getName(), end - start, 1);
start = end;
}
try {
if (!rule.usesRuleChain() && applies(rule, ctx.getLanguageVersion())) {
rule.apply(acuList, ctx);
long end = System.nanoTime();
Benchmarker.mark(Benchmark.Rule, rule.getName(), end - start, 1);
start = end;
}
} catch (ThreadDeath td) {
throw td;
} catch (Throwable t) {
LOG.log(Level.WARNING, "Exception applying rule " + rule.getName() + ", continuing with next rule", t);
}
}
}

View File

@ -150,9 +150,7 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter {
}
} catch (ClassNotFoundException e) {
LOG.log(Level.FINE, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage());
} catch (NoClassDefFoundError e) {
LOG.log(Level.WARNING, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage());
} catch (ClassFormatError e) {
} catch (LinkageError e) {
LOG.log(Level.WARNING, "Could not find class " + className + ", due to: " + e.getClass().getName() + ": " + e.getMessage());
} finally {
populateImports(node);
@ -636,9 +634,7 @@ public class ClassTypeResolver extends JavaParserVisitorAdapter {
myType = pmdClassLoader.loadClass(qualifiedName);
} catch (ClassNotFoundException e) {
myType = processOnDemand(qualifiedName);
} catch (NoClassDefFoundError e) {
myType = processOnDemand(qualifiedName);
} catch (ClassFormatError e) {
} catch (LinkageError e) {
myType = processOnDemand(qualifiedName);
}
}