aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-07-04 08:54:15 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-07-04 09:34:00 +0200
commit3e243829512cf5d818a2dc9d167277026fe4240a (patch)
tree00ba7df9aa710fb018d00c84584749c575f16ad3
parentc561396fb47457704a2ebc12f6fd153ab7706ccb (diff)
downloadsonarqube-3e243829512cf5d818a2dc9d167277026fe4240a.tar.gz
sonarqube-3e243829512cf5d818a2dc9d167277026fe4240a.zip
fix quality flaw (removed non necessary try/catch)
-rw-r--r--sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java23
1 files changed, 12 insertions, 11 deletions
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 6dd84f084df..fda4682574a 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
@@ -201,21 +201,22 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial
@Override
public Date getLastSynchronization() {
Date date;
- try {
- SearchRequestBuilder request = getClient().prepareSearch(this.getIndexName())
- .setTypes(this.getIndexType())
- .setQuery(QueryBuilders.matchAllQuery())
- .setSize(0)
- .addAggregation(AggregationBuilders.max("latest")
- .field(BaseNormalizer.UPDATED_AT_FIELD));
+ SearchRequestBuilder request = getClient().prepareSearch(this.getIndexName())
+ .setTypes(this.getIndexType())
+ .setQuery(QueryBuilders.matchAllQuery())
+ .setSize(0)
+ .addAggregation(AggregationBuilders.max("latest")
+ .field(BaseNormalizer.UPDATED_AT_FIELD));
- SearchResponse response = request.get();
+ SearchResponse response = request.get();
- Max max = (Max) response.getAggregations().get("latest");
- return new DateTime(Double.valueOf(max.getValue()).longValue()).toDate();
- } catch (Exception e) {
+ Max max = (Max) response.getAggregations().get("latest");
+ if (Double.isNaN(max.getValue())) {
date = new Date(0L);
+ } else {
+ date = new DateTime(Double.valueOf(max.getValue()).longValue()).toDate();
}
+
LOG.info("Index {}:{} has last update of {}", this.getIndexName(), this.getIndexType(), date);
return date;
}