Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8208779

SynchronizedRandomAccessList.writeReplace doesn't pass mutex to the newly created SynchronizedList

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 1.4.0
    • core-libs
    • None

      java.util.Collection.SynchronizedCollection uses a "mutex" Object field to track the object to synchronize on. For serialization, SynchronizedCollection.writeObject() also synchronizes on this "mutex".

      SynchronizedRandomAccessList is a subclass of that base class, and to allow it to deserialize on pre-1.4 JDK, it has a writeReplace() method that replaces itself with a SynchronizedList for serialization.

      Unfortunately, this SynchronizedRandomAccessList.writeReplace() method doesn't pass down the "mutex" field into the newly created SynchronizedList, so the mutex used for serializing this SynchronizedList is different from the current SynchronizedRandomAccessList. That can lead to race conditions of manipulating the SynchronizedRandomAccessList while in progress of synchronization.

            smarks Stuart Marks
            kmo Krystal Mo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: