aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
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);
}
}