You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Michael Pradel (JIRA)" <ji...@apache.org> on 2012/07/27 12:03:34 UTC

[jira] [Created] (OPENJPA-2243) Deadlock involving FormatPreservingProperties

Michael Pradel created OPENJPA-2243:
---------------------------------------

             Summary: Deadlock involving FormatPreservingProperties
                 Key: OPENJPA-2243
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2243
             Project: OpenJPA
          Issue Type: Bug
          Components: lib
    Affects Versions: 2.2.0
         Environment: All environments
            Reporter: Michael Pradel


FormatPreservingProperties extends Properties, which is a thread-safe class, but it does not preserve the thread safety. This leads to surprising deadlocks if you have a reference of type Properties, because it may turn out to be not thread-safe (despite being documented as such).

Here's a simplified example that shows how we hit this bug:

final Properties p1 = new Properties();
final Properties p2 = createPropsWithDefault(p1);
p2.put(p2, p2);
		
Thread t1 = new Thread(new Runnable() {
  public void run() { p2.remove(p1); }
});

Thread t2 = new Thread(new Runnable() {
  public void run() { p2.stringPropertyNames(); }
});
t1.start();
t2.start();
try { t1.join(); t2.join();
} catch (InterruptedException e) { e.printStackTrace(); }

Properties createPropsWithDefault(Properties p) {
  // return new Properties(p); // OK 
  return new FormatPreservingProperties(p); // leads to deadlock
}


If createPropsWithDefault() returns Properties, everything is OK (as it should be, because Properties is thread-safe). However, if it returns FormatPreservingProperties, we occasionally get a deadlock.

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.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (OPENJPA-2243) Deadlock involving FormatPreservingProperties

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee reassigned OPENJPA-2243:
-----------------------------------

    Assignee: Albert Lee
    
> Deadlock involving FormatPreservingProperties
> ---------------------------------------------
>
>                 Key: OPENJPA-2243
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2243
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: lib
>    Affects Versions: 2.2.0
>         Environment: All environments
>            Reporter: Michael Pradel
>            Assignee: Albert Lee
>         Attachments: OPENJPA-2243.patch
>
>
> FormatPreservingProperties extends Properties, which is a thread-safe class, but it does not preserve the thread safety. This leads to surprising deadlocks if you have a reference of type Properties, because it may turn out to be not thread-safe (despite being documented as such).
> Here's a simplified example that shows how we hit this bug:
> final Properties p1 = new Properties();
> final Properties p2 = createPropsWithDefault(p1);
> p2.put(p2, p2);
> 		
> Thread t1 = new Thread(new Runnable() {
>   public void run() { p2.remove(p1); }
> });
> Thread t2 = new Thread(new Runnable() {
>   public void run() { p2.stringPropertyNames(); }
> });
> t1.start();
> t2.start();
> try { t1.join(); t2.join();
> } catch (InterruptedException e) { e.printStackTrace(); }
> Properties createPropsWithDefault(Properties p) {
>   // return new Properties(p); // OK 
>   return new FormatPreservingProperties(p); // leads to deadlock
> }
> If createPropsWithDefault() returns Properties, everything is OK (as it should be, because Properties is thread-safe). However, if it returns FormatPreservingProperties, we occasionally get a deadlock.
> 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.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (OPENJPA-2243) Deadlock involving FormatPreservingProperties

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee updated OPENJPA-2243:
--------------------------------

    Patch Info: Patch Available
    
> Deadlock involving FormatPreservingProperties
> ---------------------------------------------
>
>                 Key: OPENJPA-2243
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2243
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: lib
>    Affects Versions: 2.2.0
>         Environment: All environments
>            Reporter: Michael Pradel
>            Assignee: Albert Lee
>         Attachments: OPENJPA-2243.patch
>
>
> FormatPreservingProperties extends Properties, which is a thread-safe class, but it does not preserve the thread safety. This leads to surprising deadlocks if you have a reference of type Properties, because it may turn out to be not thread-safe (despite being documented as such).
> Here's a simplified example that shows how we hit this bug:
> final Properties p1 = new Properties();
> final Properties p2 = createPropsWithDefault(p1);
> p2.put(p2, p2);
> 		
> Thread t1 = new Thread(new Runnable() {
>   public void run() { p2.remove(p1); }
> });
> Thread t2 = new Thread(new Runnable() {
>   public void run() { p2.stringPropertyNames(); }
> });
> t1.start();
> t2.start();
> try { t1.join(); t2.join();
> } catch (InterruptedException e) { e.printStackTrace(); }
> Properties createPropsWithDefault(Properties p) {
>   // return new Properties(p); // OK 
>   return new FormatPreservingProperties(p); // leads to deadlock
> }
> If createPropsWithDefault() returns Properties, everything is OK (as it should be, because Properties is thread-safe). However, if it returns FormatPreservingProperties, we occasionally get a deadlock.
> 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.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (OPENJPA-2243) Deadlock involving FormatPreservingProperties

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee updated OPENJPA-2243:
--------------------------------

    Attachment: OPENJPA-2243.patch
    
> Deadlock involving FormatPreservingProperties
> ---------------------------------------------
>
>                 Key: OPENJPA-2243
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2243
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: lib
>    Affects Versions: 2.2.0
>         Environment: All environments
>            Reporter: Michael Pradel
>         Attachments: OPENJPA-2243.patch
>
>
> FormatPreservingProperties extends Properties, which is a thread-safe class, but it does not preserve the thread safety. This leads to surprising deadlocks if you have a reference of type Properties, because it may turn out to be not thread-safe (despite being documented as such).
> Here's a simplified example that shows how we hit this bug:
> final Properties p1 = new Properties();
> final Properties p2 = createPropsWithDefault(p1);
> p2.put(p2, p2);
> 		
> Thread t1 = new Thread(new Runnable() {
>   public void run() { p2.remove(p1); }
> });
> Thread t2 = new Thread(new Runnable() {
>   public void run() { p2.stringPropertyNames(); }
> });
> t1.start();
> t2.start();
> try { t1.join(); t2.join();
> } catch (InterruptedException e) { e.printStackTrace(); }
> Properties createPropsWithDefault(Properties p) {
>   // return new Properties(p); // OK 
>   return new FormatPreservingProperties(p); // leads to deadlock
> }
> If createPropsWithDefault() returns Properties, everything is OK (as it should be, because Properties is thread-safe). However, if it returns FormatPreservingProperties, we occasionally get a deadlock.
> 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.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira