]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3126 Fix side effect of this ticket: PropertiesBackup
authorFabrice Bellingard <bellingard@gmail.com>
Sun, 20 May 2012 13:33:23 +0000 (15:33 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Sun, 20 May 2012 13:33:23 +0000 (15:33 +0200)
=> 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/src/main/java/org/sonar/server/configuration/PropertiesBackup.java
sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties-result.xml
sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportProperties.xml

index b632f0b0d5ef118c85a36a1f6be7046e8c070379..5c08b5e0a846e4463ce5517cfa6bf8ab6f043586 100644 (file)
@@ -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) {
index 6fd229689caa85a10387f12d689bb6af7e742e12..ee0bfbe99644a48cde4478515815660fbd7eecae 100644 (file)
   <properties id="4" prop_key="user_prop" text_value="[null]" resource_id="[null]" user_id="3"/>
   <properties id="5" prop_key="favorite" text_value="[null]" resource_id="8" user_id="3"/>
 
-  <properties id="6" prop_key="key1" text_value="value1" resource_id="[null]" user_id="[null]"/>
-  <properties id="7" prop_key="key2" text_value="value2" resource_id="[null]" user_id="[null]"/>
-  <properties id="8" prop_key="key3" text_value="value3" resource_id="[null]" user_id="[null]"/>
+  <!-- Sonar Core properties that were not purged -->
+  <properties id="6" prop_key="sonar.core.id" text_value="123456" resource_id="[null]" user_id="[null]"/>
+  <properties id="7" prop_key="sonar.core.version" text_value="3.1" resource_id="[null]" user_id="[null]"/>
+  <properties id="8" prop_key="sonar.core.startTime" text_value="2012-04-19T11:01:45+0200" resource_id="[null]" user_id="[null]"/>
+
+  <!-- New properties that were imported -->
+  <properties id="9" prop_key="key1" text_value="value1" resource_id="[null]" user_id="[null]"/>
+  <properties id="10" prop_key="key2" text_value="value2" resource_id="[null]" user_id="[null]"/>
+  <properties id="11" prop_key="key3" text_value="value3" resource_id="[null]" user_id="[null]"/>
 </dataset>
\ No newline at end of file
index abdf1e071d449452ed10a86994d2ecc195c551e8..a820b74a25b2679b52cc7d9306965c6ed04159da 100644 (file)
@@ -10,4 +10,9 @@
   <properties id="4" prop_key="user_prop" text_value="[null]" resource_id="[null]" user_id="3"/>
   <properties id="5" prop_key="favorite" text_value="[null]" resource_id="8" user_id="3"/>
 
+  <!-- Sonar Core properties that must not be purged -->
+  <properties id="6" prop_key="sonar.core.id" text_value="123456" resource_id="[null]" user_id="[null]"/>
+  <properties id="7" prop_key="sonar.core.version" text_value="3.1" resource_id="[null]" user_id="[null]"/>
+  <properties id="8" prop_key="sonar.core.startTime" text_value="2012-04-19T11:01:45+0200" resource_id="[null]" user_id="[null]"/>
+  
 </dataset>
\ No newline at end of file