Menu

#36 CM should not add multiple listeners to same config

open
nobody
jConfig (29)
5
2008-04-06
2008-04-06
No

The load method of ConfigurationManager has this:

if(configurationHandler instanceof AbstractHandler) {
((AbstractHandler)configurationHandler).addFileListener(new ConfigurationFileListener(configurationName));
}
if (config != null) {
//config.setConfigName(configurationName);
configurations.put(configurationName, config);
handlerMapping.put(configurationName, configurationHandler);
}

Since configurations is a hashmap, if the same configuration is loaded multiple times, one will overwrite the other. That's a good thing; you maintain just one config of given name. However, the first condition doesn't check for that, but blindly adds a new listener every time the load function is called. The result is that if the load method is called 10 times for the same config, you end up with 1 config (good) but 10 listeners (bad).

Discussion


Log in to post a comment.