Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-1934

Incorrect double-check locking

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Auto Closed
    • None
    • None
    • None
    • None
    • Patch

    Description

      http://www.cs.umd.edu/%7Epugh/java/memoryModel/DoubleCheckedLocking.html

       public BeanManagerImpl getBeanManagerImpl() {
              if (bm == null) { // should be done in the constructor
                  synchronized (this) {
                      if (bm == null) {
                          bm = new WebappBeanManager(this);
                      }
                  }
              }
              return bm;
          }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              SvetlinZarev Svetlin Zarev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: