From: Fabrice Bellingard Date: Mon, 21 May 2012 06:56:50 +0000 (+0200) Subject: SONAR-3126 Ignore "sonar.core.id" when exporting properties X-Git-Tag: 3.1~166 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=698e779ba5a3ede463ecfe03302880f91073fc6a;p=sonarqube.git SONAR-3126 Ignore "sonar.core.id" when exporting properties --- diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java index 85f0a56f243..da419f65b26 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java @@ -44,7 +44,11 @@ public class PropertiesBackup implements Backupable { List dbProperties = databaseSession.createQuery(FROM_GLOBAL_PROPERTIES).getResultList(); if (dbProperties != null) { for (Property dbProperty : dbProperties) { - xmlProperties.add(new Property(dbProperty.getKey(), dbProperty.getValue())); + String propKey = dbProperty.getKey(); + if (!CoreProperties.SERVER_ID.equals(propKey)) { + // "sonar.core.id" must never be restored, it is unique for a server and it created once at the 1rst server startup + xmlProperties.add(new Property(dbProperty.getKey(), dbProperty.getValue())); + } } sonarConfig.setProperties(xmlProperties); } diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java index 275be22557d..d8f207ac833 100644 --- a/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java +++ b/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java @@ -54,8 +54,9 @@ public class PropertiesBackupTest extends AbstractDbUnitTestCase { Property prop1 = new Property("key1", "value1"); Property prop2 = new Property("key2", "value2"); + Property prop3 = new Property("sonar.core.version", "3.1"); - assertTrue(CollectionUtils.isEqualCollection(sonarConfig.getProperties(), Arrays.asList(prop1, prop2))); + assertTrue(CollectionUtils.isEqualCollection(sonarConfig.getProperties(), Arrays.asList(prop1, prop2, prop3))); } @Test diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldExportProperties.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldExportProperties.xml index 2067cd1bcd2..0465db20f30 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldExportProperties.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldExportProperties.xml @@ -1,4 +1,10 @@ + + + + + + \ No newline at end of file