List<Property> 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);
}
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
<dataset>
<properties id="1" prop_key="key1" text_value="value1" resource_id="[null]" user_id="[null]"/>
<properties id="2" prop_key="key2" text_value="value2" resource_id="[null]" user_id="[null]"/>
+
+ <!-- Sonar Core property that should not be exported -->
+ <properties id="3" prop_key="sonar.core.id" text_value="123456" resource_id="[null]" user_id="[null]"/>
+
+ <!-- Sonar Core property that should be exported -->
+ <properties id="4" prop_key="sonar.core.version" text_value="3.1" resource_id="[null]" user_id="[null]"/>
</dataset>
\ No newline at end of file