Derby
  1. Derby
  2. DERBY-4723

Using an instance lock to protect static shared data in EmbedPooledConnection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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++; }

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Kristian Waagan
              Reporter:
              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

                  Development