aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-05 16:14:25 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-05 16:14:25 +0200
commit6608409f23925f430a75203f05454bc60e4ebf9b (patch)
tree7459275fbb8350e0f22be1fcfe0071ed52820c4c
parentac2ea1796c61120f34697161f0545f03aded41ea (diff)
downloadsonarqube-6608409f23925f430a75203f05454bc60e4ebf9b.tar.gz
sonarqube-6608409f23925f430a75203f05454bc60e4ebf9b.zip
Fix Quality flaws
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsMonitor.java1
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java9
4 files changed, 8 insertions, 6 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java
index 05815aed2b5..f36ff2c2251 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java
@@ -172,7 +172,7 @@ public class CeServer implements Monitored {
Thread.sleep(CHECK_FOR_STOP_DELAY);
} catch (InterruptedException e) {
// ignore the interruption itself
- // Do not propagate the isInterrupted flag with : Thread.currentThread().interrupt();
+ // Do not propagate the isInterrupted flag with Thread.currentThread().interrupt()
// It will break the shutdown of ComputeEngineContainerImpl#stop()
}
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
index 9cee5a621bb..523ed681652 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
@@ -66,7 +66,7 @@ import static org.sonar.process.cluster.ClusterObjectKeys.OPERATIONAL_PROCESSES;
import static org.sonar.process.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
public class HazelcastCluster implements AutoCloseable {
- private static Logger LOGGER = LoggerFactory.getLogger(HazelcastCluster.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(HazelcastCluster.class);
private final List<AppStateListener> listeners = new ArrayList<>();
private final ReplicatedMap<ClusterProcess, Boolean> operationalProcesses;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsMonitor.java
index 1c64ade4c1b..fcc3ccb32e2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsMonitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsMonitor.java
@@ -126,7 +126,6 @@ public class EsMonitor extends BaseMonitorMBean implements EsMonitorMBean {
nodeAttributes.put("Request Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getEstimated()));
nodeAttributes.put("Query Cache Memory", byteCountToDisplaySize(stats.getIndices().getQueryCache().getMemorySizeInBytes()));
nodeAttributes.put("Request Cache Memory", byteCountToDisplaySize(stats.getIndices().getRequestCache().getMemorySizeInBytes()));
- nodeAttributes.put("Query Cache Memory", byteCountToDisplaySize(stats.getIndices().getQueryCache().getMemorySizeInBytes()));
}
return nodes;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
index 1752bbd4c97..941cc2835bf 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
@@ -82,9 +82,12 @@ public class RuleCreator {
RuleKey customRuleKey = RuleKey.of(templateRule.getRepositoryKey(), newRule.ruleKey());
- loadRule(customRuleKey, dbSession)
- .map(existingRule -> updateExistingRule(existingRule, newRule, dbSession))
- .orElseGet(() -> createCustomRule(customRuleKey, newRule, templateRule, dbSession));
+ Optional<RuleDefinitionDto> definition = loadRule(customRuleKey, dbSession);
+ if (definition.isPresent()) {
+ updateExistingRule(definition.get(), newRule, dbSession);
+ } else {
+ createCustomRule(customRuleKey, newRule, templateRule, dbSession);
+ }
ruleIndexer.commitAndIndex(dbSession, customRuleKey);
return customRuleKey;