aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-07-04 09:28:18 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-07-04 09:34:08 +0200
commit605d2ad539c8962454b3ec35874b3222326eabb0 (patch)
tree05f7c1f44748f4cc0e11154fe9e47aaaee9712c8
parent3e243829512cf5d818a2dc9d167277026fe4240a (diff)
downloadsonarqube-605d2ad539c8962454b3ec35874b3222326eabb0.tar.gz
sonarqube-605d2ad539c8962454b3ec35874b3222326eabb0.zip
SONAR-5007 - Fix date-synch for ES Synchronizer when date == null (initial start)
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java7
-rw-r--r--sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java3
3 files changed, 6 insertions, 6 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java b/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java
index c7cd45ef14a..f1476dafc5b 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java
@@ -35,7 +35,6 @@ import org.sonar.server.search.action.IndexAction;
import org.sonar.server.search.action.KeyIndexAction;
import javax.annotation.CheckForNull;
-
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
@@ -103,6 +102,7 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> {
RuleKey.of(map.get("repoField"), map.get("ruleField"))));
}
});
+ session.commit();
}
/**
diff --git a/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java b/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java
index fda4682574a..abd9c742e70 100644
--- a/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java
+++ b/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java
@@ -211,10 +211,11 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial
SearchResponse response = request.get();
Max max = (Max) response.getAggregations().get("latest");
- if (Double.isNaN(max.getValue())) {
- date = new Date(0L);
- } else {
+
+ if (max.getValue() > 0) {
date = new DateTime(Double.valueOf(max.getValue()).longValue()).toDate();
+ } else {
+ date = new Date(0L);
}
LOG.info("Index {}:{} has last update of {}", this.getIndexName(), this.getIndexType(), date);
diff --git a/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java b/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
index 0bb354aa314..18c0490a438 100644
--- a/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
+++ b/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
@@ -52,7 +52,7 @@ public class IndexSynchronizer {
synchronize(session, db.activeRuleDao(), index.get(ActiveRuleIndex.class));
synchronize(session, db.activityDao(), index.get(ActivityIndex.class));
session.commit();
- LOG.info("Synchronization done in {}ms...", System.currentTimeMillis()-start);
+ LOG.info("Synchronization done in {}ms...", System.currentTimeMillis() - start);
session.close();
}
@@ -60,6 +60,5 @@ public class IndexSynchronizer {
long start = System.currentTimeMillis();
dao.synchronizeAfter(session,
index.getLastSynchronization());
- LOG.info("-- Synchronized {} in {}ms", index.getIndexType(), System.currentTimeMillis() - start);
}
}