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

Using an instance lock to protect static shared data in EmbedPooledConnection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.5.1.1
    • 10.5.3.2, 10.6.2.4, 10.7.1.1
    • JDBC
    • 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

        1. derby-4723-1a-remove_code.diff
          1 kB
          Kristian Waagan

        Issue Links

          Activity

            People

              kristwaa Kristian Waagan
              cashcrop Wendy Feng
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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