From: Teryk Bellahsene Date: Thu, 26 Nov 2015 14:27:13 +0000 (+0100) Subject: SONAR-7083 Search for active rules when a parameter value is null X-Git-Tag: 5.3-RC1~150 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=30966aeb6cda4fc24b0f6f0701a9507f3c623397;p=sonarqube.git SONAR-7083 Search for active rules when a parameter value is null --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java index e221b5e16cc..a098399cebb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java @@ -40,6 +40,7 @@ import org.sonarqube.ws.Rules; import org.sonarqube.ws.Rules.SearchResponse; import org.sonarqube.ws.Rules.ShowResponse; +import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.collect.Sets.newHashSet; /** @@ -94,7 +95,7 @@ public class ActiveRuleCompleter { } } - private Collection writeActiveRules(RuleKey ruleKey, Collection activeRules, Rules.Actives.Builder activesBuilder) { + private static Collection writeActiveRules(RuleKey ruleKey, Collection activeRules, Rules.Actives.Builder activesBuilder) { Collection qProfileKeys = newHashSet(); Rules.ActiveList.Builder activeRulesListResponse = Rules.ActiveList.newBuilder(); for (ActiveRule activeRule : activeRules) { @@ -107,7 +108,7 @@ public class ActiveRuleCompleter { return qProfileKeys; } - private Rules.Active buildActiveRuleResponse(ActiveRule activeRule) { + private static Rules.Active buildActiveRuleResponse(ActiveRule activeRule) { Rules.Active.Builder activeRuleResponse = Rules.Active.newBuilder(); activeRuleResponse.setQProfile(activeRule.key().qProfile()); activeRuleResponse.setInherit(activeRule.inheritance().toString()); @@ -120,7 +121,7 @@ public class ActiveRuleCompleter { for (Map.Entry param : activeRule.params().entrySet()) { activeRuleResponse.addParams(paramBuilder.clear() .setKey(param.getKey()) - .setValue(param.getValue())); + .setValue(nullToEmpty(param.getValue()))); } return activeRuleResponse.build();