Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4723

Using an instance lock to protect static shared data in EmbedPooledConnection

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1
    • Fix Version/s: 10.5.3.2, 10.6.2.4, 10.7.1.1
    • Component/s: JDBC
    • Labels:
      None

      Description

      EmbedPooledConnection has the unsafe synchronization as follow.

      private static int idCounter = 0;

      private synchronized int nextId()

      { return idCounter++; }

      idCounter is a static shared data, and it is not proper to use a instance lock to protect it, especially when two instance of the class are created.

      it would be more safer to write this instead:

      private static synchronized int nextId()
      { return idCounter++; }

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              kristwaa Kristian Waagan
              Reporter:
              cashcrop Wendy Feng

              Dates

              • Created:
                Updated:
                Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Issue deployment