From 7f3da255793c2a0ed4b25df593f159e8cb13a19c Mon Sep 17 00:00:00 2001 From: Jacek Date: Fri, 21 Oct 2022 15:08:31 +0200 Subject: SONAR-17331 Log message when Elasticsearch index requires re-indexing --- .../main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sonar-scanner-engine/src/main/java') 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 loadedRules = new LinkedList<>(); List rulesList = response.getRulesList(); - Map actives = response.getActives().getActives(); + Map 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(); -- cgit v1.2.3