aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2022-10-21 15:08:31 +0200
committersonartech <sonartech@sonarsource.com>2022-10-24 20:04:04 +0000
commit7f3da255793c2a0ed4b25df593f159e8cb13a19c (patch)
tree772b0bba9df3703857cbbd4d299ca60a4796c57e /sonar-scanner-engine/src/main/java
parenteb249087f989c12a7e25c72a91a8eb7cd3ef0a9d (diff)
downloadsonarqube-7f3da255793c2a0ed4b25df593f159e8cb13a19c.tar.gz
sonarqube-7f3da255793c2a0ed4b25df593f159e8cb13a19c.zip
SONAR-17331 Log message when Elasticsearch index requires re-indexing
Diffstat (limited to 'sonar-scanner-engine/src/main/java')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
index ea1a0f6abfb..7bd76d47e03 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
@@ -31,6 +31,7 @@ import org.sonar.api.batch.rule.LoadedActiveRule;
import org.sonar.api.impl.utils.ScannerUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.MessageException;
import org.sonar.scanner.bootstrap.ScannerWsClient;
import org.sonarqube.ws.Rules;
import org.sonarqube.ws.Rules.Active;
@@ -96,10 +97,14 @@ public class DefaultActiveRulesLoader implements ActiveRulesLoader {
List<LoadedActiveRule> loadedRules = new LinkedList<>();
List<Rule> rulesList = response.getRulesList();
- Map<String, ActiveList> actives = response.getActives().getActives();
+ Map<String, ActiveList> actives = response.getActives().getActivesMap();
for (Rule r : rulesList) {
ActiveList activeList = actives.get(r.getKey());
+ if (activeList == null) {
+ throw MessageException.of("Elasticsearch indices have become inconsistent. Consider re-indexing. " +
+ "Check documentation for more information https://docs.sonarqube.org/latest/setup/troubleshooting");
+ }
Active active = activeList.getActiveList(0);
LoadedActiveRule loadedRule = new LoadedActiveRule();