You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/06/13 10:23:00 UTC

[jira] [Commented] (TOMEE-1934) Incorrect double-check locking

    [ https://issues.apache.org/jira/browse/TOMEE-1934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047704#comment-16047704 ] 

ASF GitHub Bot commented on TOMEE-1934:
---------------------------------------

Github user SvetlinZarev closed the pull request at:

    https://github.com/apache/tomee/pull/41


> Incorrect double-check locking
> ------------------------------
>
>                 Key: TOMEE-1934
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1934
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>            Priority: Trivial
>
> http://www.cs.umd.edu/%7Epugh/java/memoryModel/DoubleCheckedLocking.html
> {code}
>  public BeanManagerImpl getBeanManagerImpl() {
>         if (bm == null) { // should be done in the constructor
>             synchronized (this) {
>                 if (bm == null) {
>                     bm = new WebappBeanManager(this);
>                 }
>             }
>         }
>         return bm;
>     }
> {code}
> Unless **bm** is volatile, multiple instances of the bean manager can be created under concurrent conditions. 
> PS: I saw the suppress warning. I'm not sure if PMD just warns against DCL or that it was broken. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)