diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index fe493e1a8..dfaff607d 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -552,7 +552,7 @@ private File getConfigurationFile() if (!(this.store instanceof XMLConfigurationStore)) this.store = new XMLConfigurationStore(); } - else if (configurationFile.exists()) + else { String name = configurationFile.getName(); int extensionBeginIndex = name.lastIndexOf('.'); @@ -583,21 +583,26 @@ else if (configurationFile.exists()) if (!(this.store instanceof PropertyConfigurationStore)) this.store = new PropertyConfigurationStore(); } + else if (!configurationFile.exists() + && (getSystemProperty(PNAME_CONFIGURATION_FILE_NAME) + == null)) + { + this.configurationFile + = getConfigurationFile("properties", true); + if (!(this.store instanceof PropertyConfigurationStore)) + this.store = new PropertyConfigurationStore(); + } else { - this.configurationFile = configurationFile; + this.configurationFile = + configurationFile.exists() + ? configurationFile + : getConfigurationFile("xml", true); if (!(this.store instanceof XMLConfigurationStore)) this.store = new XMLConfigurationStore(); } } } - else - { - this.configurationFile - = getConfigurationFile("properties", true); - if (!(this.store instanceof PropertyConfigurationStore)) - this.store = new PropertyConfigurationStore(); - } /* * Make sure that the properties SC_HOME_DIR_LOCATION and @@ -914,6 +919,9 @@ public void purgeStoredConfiguration() configurationFile.delete(); configurationFile = null; } + if (store != null) + for (String name : store.getPropertyNames()) + store.removeProperty(name); } /** diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java index 65f52d62e..e9505a267 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationSlickFinalizer.java @@ -6,10 +6,13 @@ */ package net.java.sip.communicator.slick.configuration; -import org.osgi.framework.*; +import java.util.*; + import junit.framework.*; import net.java.sip.communicator.service.configuration.*; +import org.osgi.framework.*; + /** * Performs finalization tasks (such as removing the configuration file) at the * end of the ConfigurationServiceLick. @@ -42,5 +45,11 @@ public void testPurgeConfiguration() configurationService.purgeStoredConfiguration(); + List propertyNames + = configurationService.getPropertyNamesByPrefix("", false); + + assertTrue( + "The configuration service contains properties after purging.", + (propertyNames == null) || (propertyNames.size() <= 0)); } }