[jboss-jira] [JBoss JIRA] (JBCOMMON-126) NullPointerException when using PropertyMap concurrently

Dimitris Andreadis (JIRA) jira-events at lists.jboss.org
Fri Aug 3 18:30:06 EDT 2012


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

Dimitris Andreadis resolved JBCOMMON-126.
-----------------------------------------

         Assignee: Dimitris Andreadis
    Fix Version/s: 2.2.20.GA
       Resolution: Done

    
> NullPointerException when using PropertyMap concurrently
> --------------------------------------------------------
>
>                 Key: JBCOMMON-126
>                 URL: https://issues.jboss.org/browse/JBCOMMON-126
>             Project: JBoss Common
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: common-core (2.x)
>    Affects Versions: 2.2.18.GA 
>         Environment: All environments
>            Reporter: Michael Pradel
>            Assignee: Dimitris Andreadis
>             Fix For: 2.2.20.GA
>
>
> PropertyMap extends Properties, which is a thread-safe class, but it doesn't preserve its thread safety. This leads to surprising crashes if you have a reference of type Properties (documented as thread-safe) that turns out to be a PropertyMap (not thread-safe).
> Here's a simplified example that shows how we hit this bug:
> final Properties p = getProps();
> p.setProperty("a", "b");
> 		
> Thread t1 = new Thread(new Runnable() {
>   public void run() { p.remove("a"); }
> });
> Thread t2 = new Thread(new Runnable() {
>   public void run() { p.clear(); }
> });
> t1.start();
> t2.start();
> try { t1.join(); t2.join(); 
> } catch (InterruptedException e) {
>   e.printStackTrace();
> }
> Properties getProps() {
>   // return new Properties(); // OK
>   return new PropertyMap(); // leads to NullPointerException
> }
> The code runs fine if getProps returns Properties (as it should, because Properties is thread-safe), but raises a NullPointerException if getProps returns a PropertyMap.
> Are you aware of this inconsistency? It seems that the safest way of extending Properties is to make methods that override synchronized methods synchronized.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list