aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-15 11:02:17 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-15 11:02:17 +0000
commit4bbf712a2f46603e76f407fa25e961ff00cacf92 (patch)
tree077813ebce7fdca79722d70da4d04f2e6335bf12 /sonar-server
parent08dd37963702aae4122387a37874dbcb6e4f1912 (diff)
downloadsonarqube-4bbf712a2f46603e76f407fa25e961ff00cacf92.tar.gz
sonarqube-4bbf712a2f46603e76f407fa25e961ff00cacf92.zip
fix a NPE when restoring a backup without node <alerts/>
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
index 3149e62923c..c1259bb32b4 100644
--- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
+++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
@@ -92,18 +92,20 @@ public class ProfilesBackup implements Backupable {
}
private void importAlerts(RulesProfile profile) {
- for (Iterator<Alert> ia = profile.getAlerts().iterator(); ia.hasNext();) {
- Alert alert = ia.next();
- Metric unMarshalledMetric = alert.getMetric();
- String validKey = unMarshalledMetric.getKey();
- Metric matchingMetricInDb = session.getSingleResult(Metric.class, "key", validKey);
- if (matchingMetricInDb == null) {
- LoggerFactory.getLogger(getClass()).error("Unable to find metric " + validKey);
- ia.remove();
- continue;
+ if (profile.getAlerts() != null) {
+ for (Iterator<Alert> ia = profile.getAlerts().iterator(); ia.hasNext();) {
+ Alert alert = ia.next();
+ Metric unMarshalledMetric = alert.getMetric();
+ String validKey = unMarshalledMetric.getKey();
+ Metric matchingMetricInDb = session.getSingleResult(Metric.class, "key", validKey);
+ if (matchingMetricInDb == null) {
+ LoggerFactory.getLogger(getClass()).error("Unable to find metric " + validKey);
+ ia.remove();
+ continue;
+ }
+ alert.setMetric(matchingMetricInDb);
+ alert.setRulesProfile(profile);
}
- alert.setMetric(matchingMetricInDb);
- alert.setRulesProfile(profile);
}
}