From 44ff7e7806469b587c1e3f252ad00d696b2b52db Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Sun, 20 May 2012 15:33:23 +0200 Subject: [PATCH] SONAR-3126 Fix side effect of this ticket: PropertiesBackup => As now Sonar batch relies on "sonar.core.id" property to check that the batch connects to the same DB as the configured remote server, this property should not be cleared when restoring a backup from the UI. Actually, every "sonar.core.*" property should not be cleared. --- .../sonar/server/configuration/PropertiesBackup.java | 4 +++- .../shouldImportProperties-result.xml | 12 +++++++++--- .../PropertiesBackupTest/shouldImportProperties.xml | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) 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 b632f0b0d5e..5c08b5e0a84 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 @@ -61,7 +61,9 @@ public class PropertiesBackup implements Backupable { } private void clearProperties() { - databaseSession.createQuery("delete " + FROM_GLOBAL_PROPERTIES).executeUpdate(); + // "sonar.core.*" properties should not be cleared, most notably "sonar.core.id" which is the unique key used to identify the server + // and which is used by the batch to verify that it connects to the same DB as the remote server (see SONAR-3126). + databaseSession.createQuery("delete " + FROM_GLOBAL_PROPERTIES + " and prop_key NOT LIKE 'sonar.core.%'").executeUpdate(); } public void configure(XStream xStream) { diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties-result.xml index 6fd229689ca..ee0bfbe9964 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties-result.xml @@ -11,7 +11,13 @@ - - - + + + + + + + + + \ No newline at end of file diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties.xml index abdf1e071d4..a820b74a25b 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties.xml @@ -10,4 +10,9 @@ + + + + + \ No newline at end of file -- 2.39.5