aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-03-20 17:21:12 +0100
committerSonarTech <sonartech@sonarsource.com>2018-03-22 12:37:50 +0100
commitb3cf89af7b9fede43d0b23739b28dc762eb3e2ad (patch)
treeec4bf793751c58f18fa29166d154135222cfa1d2 /server
parent4bfc03f1f36682fdb77f68df35c59e1b24d1a293 (diff)
downloadsonarqube-b3cf89af7b9fede43d0b23739b28dc762eb3e2ad.tar.gz
sonarqube-b3cf89af7b9fede43d0b23739b28dc762eb3e2ad.zip
SONAR-10502 Fix concurrency error during initial indexing
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/IndexingListener.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/IndexingResult.java18
2 files changed, 10 insertions, 10 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexingListener.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexingListener.java
index 44e04c18ca6..3c869401c39 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexingListener.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexingListener.java
@@ -36,7 +36,7 @@ public interface IndexingListener {
@Override
public void onFinish(IndexingResult result) {
if (result.getFailures() > 0) {
- throw new IllegalStateException("Unrecoverable indexation failures");
+ throw new IllegalStateException(String.format("Unrecoverable indexation failures: %d errors among %d requests", result.getFailures(), result.getTotal()));
}
}
};
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexingResult.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexingResult.java
index fac20747be1..5b7386d178e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexingResult.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexingResult.java
@@ -24,12 +24,12 @@ import java.util.concurrent.atomic.AtomicLong;
public class IndexingResult {
// FIXME should be private
- AtomicLong total = new AtomicLong(0L);
- private long successes = 0L;
+ final AtomicLong total = new AtomicLong(0L);
+ private final AtomicLong successes = new AtomicLong(0L);
IndexingResult clear() {
total.set(0L);
- successes = 0L;
+ successes.set(0L);
return this;
}
@@ -38,17 +38,17 @@ public class IndexingResult {
}
public IndexingResult incrementSuccess() {
- successes += 1;
+ successes.incrementAndGet();
return this;
}
public void add(IndexingResult other) {
total.addAndGet(other.total.get());
- successes += other.successes;
+ successes.addAndGet(other.successes.get());
}
public long getFailures() {
- return total.get() - successes;
+ return total.get() - successes.get();
}
public long getTotal() {
@@ -56,14 +56,14 @@ public class IndexingResult {
}
public long getSuccess() {
- return successes;
+ return successes.get();
}
public double getSuccessRatio() {
- return total.get() == 0 ? 1.0 : ((1.0 * successes) / total.get());
+ return total.get() == 0 ? 1.0 : ((1.0 * successes.get()) / total.get());
}
public boolean isSuccess() {
- return total.get() == successes;
+ return total.get() == successes.get();
}
}