Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-8085

Fix potential race condition in REST initialization found by PMD

    Details

    • Issue discovered during:
      Jenkins
    • Sprint:
      EJBCA Team Bob - 2019 w13

      Description

      Fix "DoubleCheckedLocking" race condition in initialization of the REST resources found by PMD.

      In short, if a variable shared by multiple threads is assigned, and the expression on the right hand side is an object construction, then an optimizing JDK is allowed to assign the variable first and then call the constructor.

      See https://pmd.github.io/latest/pmd_rules_java_multithreading.html

      Be aware that the top Google results on this are from the JDK 1.4 times (and earlier), and suggest the "double-checked locking" is an anti-pattern. That was perhaps true back then. The proper fix since JDK 1.5 is to make the variables volatile.

        Attachments

          Activity

            People

            • Assignee:
              samuel Samuel Lidén Borell
              Reporter:
              samuel Samuel Lidén Borell
              Verified by:
              Andrey Sergeev
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Time Spent - 15 minutes Remaining Estimate - 45 minutes
                45m
                Logged:
                Time Spent - 15 minutes Remaining Estimate - 45 minutes
                15m