Derby
  1. Derby
  2. DERBY-5561

Race conditions in LogicalConnection checking for a null physical connection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.3.2, 10.8.2.2
    • Component/s: Network Client
    • Labels:
      None
    • Environment:
      Solaris 10
      Glassfish V2.1.1
      ClientXADataSource connection pool
    • Urgency:
      Urgent
    • Issue & fix info:
      High Value Fix
    • Bug behavior facts:
      Crash, Seen in production

      Description

      There are race conditions with checkForNullPhysicalConnection calls in LogicalConnection. checkForNullPhysicalConnection is not synchronized and it checks for the member "phsyicalConnection" which can be cleared by "nullPhsyicalConnection" (which is synchronized) and "close" (which is synchronized) and "closeWithoutRecyclingToPool" (which is synchronized).

      This affects "nativeSQL", "getAutoCommit", "getTransactionIsolation", "getWarnings", "isReadOnly", "getCatalog", "getTypeMap", "createStatement", "prepareCall", "prepareStatement", "setHoldability", "getHoldability", "setSavePoint", "rollBack", "releaseSavePoint", "getSchema", "setSchema".

      All of these call "checkForNullPhysicalConnection" and then use the member "physicalConnection" after that call returns. Because these methods are not synchronized, between the time "checkForNullPhysicalConnectoin" returns and "physicalConnection" is used, the "physicalConnection" member could be set to null and then a NPE occurs.

      Probably all of these methods should be changed to synchronized.

      1. derby-5561-2a-minor_cleanups.diff
        4 kB
        Kristian Waagan
      2. DERBY-5561.patch
        7 kB
        Brett Bergquist

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Kristian Waagan
            Reporter:
            Brett Bergquist
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development