eclipse plugin: Remove the need of syncronization by correctly...

...creating the singleton. This uses the IODH idiom

More info at: http://www.ibm.com/developerworks/java/library/j-dcl/index.html

Issue found by "FindBugs"
This commit is contained in:
Timotei Dolean 2011-04-10 10:34:31 +00:00
parent 7a593813e0
commit 62460f6828

View file

@ -28,17 +28,23 @@ import org.wesnoth.utils.StringUtils;
public class TemplateProvider
{
private static TemplateProvider instance_;
/**
* Holds the instance of the TemplateProvider.
* This is based on the Initialization on demand holder idiom
*/
private static class TemplateProviderInstance{
private static final TemplateProvider instance_ = new TemplateProvider();
}
private final Map<String, String> templates_ = new HashMap<String, String>();
public static TemplateProvider getInstance()
private TemplateProvider(){
loadTemplates();
}
public static TemplateProvider getInstance()
{
if (instance_ == null)
{
instance_ = new TemplateProvider();
instance_.loadTemplates();
}
return instance_;
return TemplateProviderInstance.instance_;
}
/**