You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2007/10/30 18:37:50 UTC

[jira] Created: (LANG-369) ExceptionUtils not thread-safe

ExceptionUtils not thread-safe
------------------------------

                 Key: LANG-369
                 URL: https://issues.apache.org/jira/browse/LANG-369
             Project: Commons Lang
          Issue Type: Bug
            Reporter: Sebb


The ExceptionUtils class does not appear to be thread-safe:
- CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
- addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
- all accesses to CAUSE_METHOD_NAMES probably need to be synchronised

The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (LANG-369) ExceptionUtils not thread-safe

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

Sebb reopened LANG-369:
-----------------------


I think the wrong lock object is used in the synchronization.

The code uses the CAUSE_METHOD_NAMES object as the lock and then changes it in the synchronized block, i.e. the lock object is changed.

This occurs in removeCauseMethodName() and addCauseMethodName().

Either lock on the class, or use a dummy static final Object as the lock.

This applies to 2.4 branch and trunk


> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-369) ExceptionUtils not thread-safe

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

Henri Yandell updated LANG-369:
-------------------------------

    Attachment: LANG-369.patch

Patch that liberally splashes synchronized around the variable.

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LANG-369) ExceptionUtils not thread-safe

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

Sebb resolved LANG-369.
-----------------------

    Resolution: Fixed

Applied patch:

URL: http://svn.apache.org/viewvc?rev=755391&view=rev
Log:
LANG-369 - must use fixed object as lock target


> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 3.0, 2.x
>
>         Attachments: LANG-369-2.patch, LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-369) ExceptionUtils not thread-safe

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

Henri Yandell updated LANG-369:
-------------------------------

    Fix Version/s:     (was: 2.4)
                   2.x
                   3.0

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 3.0, 2.x
>
>         Attachments: LANG-369-2.patch, LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (LANG-369) ExceptionUtils not thread-safe

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

Henri Yandell closed LANG-369.
------------------------------

    Resolution: Fixed

svn ci -m "Applying the synchronization from LANG-369" src/java/org/apache/commons/lang/exception/ExceptionUtils.java

Sending        src/java/org/apache/commons/lang/exception/ExceptionUtils.java
Transmitting file data .
Committed revision 594278.

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-369) ExceptionUtils not thread-safe

Posted by "Ben Speakmon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541917 ] 

Ben Speakmon commented on LANG-369:
-----------------------------------

Patch looks safe.

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-369) ExceptionUtils not thread-safe

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

Sebb updated LANG-369:
----------------------

    Attachment: LANG-369-2.patch

Patch which adds static final Object as a lock.

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: LANG-369-2.patch, LANG-369.patch
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-369) ExceptionUtils not thread-safe

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

Henri Yandell updated LANG-369:
-------------------------------

    Fix Version/s: 2.4

Agreed - synchronizing the variable seems the best thing to do.

> ExceptionUtils not thread-safe
> ------------------------------
>
>                 Key: LANG-369
>                 URL: https://issues.apache.org/jira/browse/LANG-369
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>
> The ExceptionUtils class does not appear to be thread-safe:
> - CAUSE_METHOD_NAMES is not final, so may not be visible to all threads
> - addCauseMethodName() and removeCauseMethodName() can update CAUSE_METHOD_NAMES but are not synch.
> - all accesses to CAUSE_METHOD_NAMES probably need to be synchronised
> The documentation does not state whether or not the class is thread-safe, but given that it only has static methods it does not make any sense unless it is thread-safe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.