forked from phoedos/pmd
Fix NPE with empty rulesets.
This is the fix for bug #1155 (https://sourceforge.net/p/pmd/bugs/1155/) The whole code is in dire need of revisiting its behaviour when a value is null or empty. Same goes for e.g. createRules whether it should return null values (then the caller will have to deal with it) or empty Rulesets. Catching and discarding the rule not found exception looks pretty suspicious.
This commit is contained in:
parent
973fd1c4d4
commit
957afd6625
@ -251,6 +251,7 @@ public class RuleSetReferenceId {
|
||||
*/
|
||||
public static List<RuleSetReferenceId> parse(String referenceString) {
|
||||
List<RuleSetReferenceId> references = new ArrayList<RuleSetReferenceId>();
|
||||
if (referenceString != null && referenceString.trim().length() > 0) {
|
||||
if (referenceString.indexOf(',') == -1) {
|
||||
references.add(new RuleSetReferenceId(referenceString));
|
||||
} else {
|
||||
@ -258,6 +259,7 @@ public class RuleSetReferenceId {
|
||||
references.add(new RuleSetReferenceId(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
return references;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public abstract class AbstractPMDProcessor {
|
||||
return factory.createRuleSets(configuration.getRuleSets());
|
||||
} catch (RuleSetNotFoundException rsnfe) {
|
||||
// should not happen: parent already created a ruleset
|
||||
return null;
|
||||
return new RuleSets();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user