[infinispan-issues] [JBoss JIRA] Resolved: (ISPN-435) NamedExecutorsFactory incorrectly uses java.util.Properties causing properties to be set to their defaults

Manik Surtani (JIRA) jira-events at lists.jboss.org
Tue May 11 07:47:05 EDT 2010


     [ https://jira.jboss.org/jira/browse/ISPN-435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manik Surtani resolved ISPN-435.
--------------------------------

    Fix Version/s: 4.1.0.BETA1
                   4.1.0.Final
       Resolution: Done


> 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
>          Components: Configuration
>    Affects Versions: 4.0.0.Final
>         Environment: ubunutu 10
>            Reporter: Daniel Cullender
>            Assignee: Manik Surtani
>             Fix For: 4.1.0.BETA1, 4.1.0.Final
>
>
> 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.
>  
>  

-- 
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

        


More information about the infinispan-issues mailing list