Uploaded image for project: 'Policy Framework'
  1. Policy Framework
  2. POLICY-511 Fix Fortify Scan Issues
  3. POLICY-540

Fix Fortify Double-Checked Locking Issue

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Medium Medium
    • None
    • None
    • None
    • None

      Many talented individuals have spent a great deal of time pondering ways to make double-checked locking work in order to improve performance. None have succeeded.
      Double-checked locking is an incorrect idiom that does not achieve the intended effect.
      Such as below
      if (fitz == null) {
      synchronized (this) {
      if (fitz == null)

      { fitz = new Fitzer(); }

      }
      }
      return fitz;
      The programmer wants to guarantee that only one Fitzer() object is ever allocated, but does not want to pay the cost of synchronization every time this code is called. This idiom is known as double-checked locking.
      Unfortunately, it does not work, and multiple Fitzer() objects can be allocated
      To fix this issue by removing the first checking.

            guangxingwang guangxingwang
            guangxingwang guangxingwang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: