Merge pull request #31 from hgschmie/npe-fix

Fix NPE with empty rulesets.
This commit is contained in:
Pelisse Romain 2013-11-26 16:50:11 -08:00
commit 80148e6b13
2 changed files with 8 additions and 6 deletions

View File

@ -251,11 +251,13 @@ public class RuleSetReferenceId {
*/ */
public static List<RuleSetReferenceId> parse(String referenceString) { public static List<RuleSetReferenceId> parse(String referenceString) {
List<RuleSetReferenceId> references = new ArrayList<RuleSetReferenceId>(); List<RuleSetReferenceId> references = new ArrayList<RuleSetReferenceId>();
if (referenceString.indexOf(',') == -1) { if (referenceString != null && referenceString.trim().length() > 0) {
references.add(new RuleSetReferenceId(referenceString)); if (referenceString.indexOf(',') == -1) {
} else { references.add(new RuleSetReferenceId(referenceString));
for (String name : referenceString.split(",")) { } else {
references.add(new RuleSetReferenceId(name)); for (String name : referenceString.split(",")) {
references.add(new RuleSetReferenceId(name));
}
} }
} }
return references; return references;

View File

@ -56,7 +56,7 @@ public abstract class AbstractPMDProcessor {
return factory.createRuleSets(configuration.getRuleSets()); return factory.createRuleSets(configuration.getRuleSets());
} catch (RuleSetNotFoundException rsnfe) { } catch (RuleSetNotFoundException rsnfe) {
// should not happen: parent already created a ruleset // should not happen: parent already created a ruleset
return null; return new RuleSets();
} }
} }