aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-core-plugin
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-23 16:41:08 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-23 16:41:08 +0000
commitc148a77de1ddabc92c5df742c5fc12a8374df2a2 (patch)
tree5eb4dcb730480040a9e4f35d4db4d9a86c721bc4 /plugins/sonar-core-plugin
parentf04225c5e377a2d928099d0c43936d689a649318 (diff)
downloadsonarqube-c148a77de1ddabc92c5df742c5fc12a8374df2a2.tar.gz
sonarqube-c148a77de1ddabc92c5df742c5fc12a8374df2a2.zip
log a warning when period properties are not valid
Diffstat (limited to 'plugins/sonar-core-plugin')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java
index 2fda1618ed0..bf7d8ba5d9f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java
@@ -22,6 +22,7 @@ package org.sonar.plugins.core.timemachine;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchExtension;
+import org.sonar.api.utils.Logs;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -35,6 +36,7 @@ public class PastSnapshotFinder implements BatchExtension {
public static final String DEFAULT_VALUE_1 = PastSnapshotFinderByPreviousAnalysis.MODE;
public static final String DEFAULT_VALUE_2 = "5";
public static final String DEFAULT_VALUE_3 = "30";
+ public static final String PROPERTY_PREFIX = "sonar.timemachine.period";
private PastSnapshotFinderByDays finderByDays;
private PastSnapshotFinderByVersion finderByVersion;
@@ -51,17 +53,22 @@ public class PastSnapshotFinder implements BatchExtension {
public PastSnapshot find(Configuration conf, int index) {
String propertyValue = getPropertyValue(conf, index);
- return find(index, propertyValue);
+ PastSnapshot pastSnapshot = find(index, propertyValue);
+ if (pastSnapshot==null && StringUtils.isNotBlank(propertyValue)) {
+ Logs.INFO.warn("The property " + PROPERTY_PREFIX + index + " has an unvalid value: " + propertyValue);
+ }
+ return pastSnapshot;
}
static String getPropertyValue(Configuration conf, int index) {
String defaultValue = null;
switch (index) {
+ // only global settings (from 1 to 3) have default values
case 1: defaultValue = DEFAULT_VALUE_1; break;
case 2: defaultValue = DEFAULT_VALUE_2; break;
case 3: defaultValue = DEFAULT_VALUE_3; break;
}
- return conf.getString("sonar.timemachine.period" + index, defaultValue);
+ return conf.getString(PROPERTY_PREFIX + index, defaultValue);
}
public PastSnapshot find(int index, String property) {