[JBoss JIRA] Created: (ISPN-435) NamedExecutorsFactory incorrectly uses java.util.Properties causing properties to be set to their defaults
by Daniel Cullender (JIRA)
NamedExecutorsFactory incorrectly uses java.util.Properties causing properties to be set to their defaults
----------------------------------------------------------------------------------------------------------
Key: ISPN-435
URL: https://jira.jboss.org/jira/browse/ISPN-435
Project: Infinispan
Issue Type: Bug
Environment: ubunutu 10
Reporter: Daniel Cullender
Assignee: Manik Surtani
A simple test case shows what the subtlety is :
Properties p = new Properties();
p.put("hi", "there");
System.out.println(p.get("hi"));
System.out.println(p.containsKey("hi"));
/*
* creates a defensive copy of p - however, this creates a reference in the
* properties object to the properties, so direct calls to the parent map do
* not work as expected
*/
Properties p2 = new Properties(p);
System.out.println(p2.get("hi"));
System.out.println(p2.containsKey("hi"));
This produces the following output
there
true
null
false
Now, Infinispan does the following org.infinispan.factories.NamedExecutorsFactory :
private ExecutorService buildAndConfigureExecutorService(String factoryName, Properties p, String componentName) throws Exception {
Properties props = new Properties(p); // defensive copy
ExecutorFactory f = (ExecutorFactory) Util.getInstance(factoryName);
setComponentName(componentName, props);
setDefaultThreads(KnownComponentNames.getDefaultThreads(componentName), props);
setDefaultThreadPrio(KnownComponentNames.getDefaultThreadPrio(componentName), props);
return f.getExecutor(props);
}
...
private void setDefaultThreadPrio(int prio, Properties props) {
if (!props.containsKey("threadPriority")) props.setProperty("threadPriority", String.valueOf(prio));
}
private void setDefaultThreads(int numThreads, Properties props) {
if (!props.containsKey("maxThreads")) props.setProperty("maxThreads", String.valueOf(numThreads));
}
The buildAndConfigureExecutorService method makes a defensive copy of the properties, but the helper methods (example : setDefaultThreads) uses the containsKey method from java.util.Properties which will return false based on the previous example.
This means that the properties specified for the Async Listeners will not be set, but rather defaulted because of this subtlety.
Before logging a Jira, does anyone know if this has been fixed and there is a patch
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira