Derby
  1. Derby
  2. DERBY-4124

Broken double-checked-locking in EmbeddedDataSource.findDriver

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.2.0
    • Fix Version/s: 10.6.1.0
    • Component/s: JDBC
    • Labels:
      None
    • Environment:
      all
    • Urgency:
      Normal

      Description

      org.apache.derby.jdbc.EmbeddedDataSource.findDriver() uses the
      double-checked-locking idiom for setting the 'driver' variable. This
      idiom is, however, not correct and hence the code is broken. The fix
      is to remove the outer if, i.e. to always enter the synchronized block.

      See also
      http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

        Activity

        Hide
        Bryan Pendleton added a comment -

        Committed to the trunk as revision 833888.

        Show
        Bryan Pendleton added a comment - Committed to the trunk as revision 833888.
        Hide
        Bryan Pendleton added a comment -

        The proposed change seems correct to me. I removed the extra 'if'
        statement and adjusted the indentation, in the attached patch.

        A complete regression test run was clean.

        I'm intending to commit this change.

        Show
        Bryan Pendleton added a comment - The proposed change seems correct to me. I removed the extra 'if' statement and adjusted the indentation, in the attached patch. A complete regression test run was clean. I'm intending to commit this change.
        Hide
        Rick Hillegas added a comment -

        Triaged July 2, 2009: Assigned normal urgency.

        Show
        Rick Hillegas added a comment - Triaged July 2, 2009: Assigned normal urgency.
        Hide
        Ronald Tschalaer added a comment -

        I think you're overreacting a bit. That site is just one of many describing the basic issue, but if you really have problems with using information from webpages (in which case I presume you must not be reading any webpages at all, lest you get tainted by information from them) then you can also go ahead and do a detailed reading of JLS which, if read correctly, will also explain why double-checked locking is broken.

        Show
        Ronald Tschalaer added a comment - I think you're overreacting a bit. That site is just one of many describing the basic issue, but if you really have problems with using information from webpages (in which case I presume you must not be reading any webpages at all, lest you get tainted by information from them) then you can also go ahead and do a detailed reading of JLS which, if read correctly, will also explain why double-checked locking is broken.
        Hide
        Myrna van Lunteren added a comment -

        I didn't look at the actual fix - just saw a document with lots of names on it and references to articles etc. If it's not going to get us into trouble it's fine with me to fix this bug, of course.

        Show
        Myrna van Lunteren added a comment - I didn't look at the actual fix - just saw a document with lots of names on it and references to articles etc. If it's not going to get us into trouble it's fine with me to fix this bug, of course.
        Hide
        Knut Anders Hatlen added a comment -

        You mean, we are not allowed to remove two lines of code?

        Show
        Knut Anders Hatlen added a comment - You mean, we are not allowed to remove two lines of code?
        Hide
        Myrna van Lunteren added a comment -

        This is an interesting observation...but I want to put in 1 cautionary comment; the stated webpage has no licensing/copyrighting info, but it's not clear to me whether the solution came from one of the mentioned articles or was found by one of the contributing/signing people.
        We can't use this fix if there's a copyright on it.

        Show
        Myrna van Lunteren added a comment - This is an interesting observation...but I want to put in 1 cautionary comment; the stated webpage has no licensing/copyrighting info, but it's not clear to me whether the solution came from one of the mentioned articles or was found by one of the contributing/signing people. We can't use this fix if there's a copyright on it.

          People

          • Assignee:
            Bryan Pendleton
            Reporter:
            Ronald Tschalaer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development