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

extraneous synchronization in collection serialization

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.2.2, 1.4.0
    • core-libs
    • None
    • mantis
    • generic
    • generic
    • Verified

      Some unsynchronized collections (ArrayList, LinkedList, HashSet and TreeSet) have synchronized readObject and writeObject methods. This is of no benefit and could even cause deadlock in applications that concurrently serialize different parts of an object graph in multiple threads. The synchronized modifier should be removed from these methods. Further, the synchronized modifier is present on the readObject method of a synchronized collection (Hashtable). This is unnecessary and should be removed. (It is, however, essential that Hashtable's writeObject method remain synchronized.) Finally, Vector uses default serialization, which is unsynchronized. We must add a synchronized writeObject method to Vector that simply calls the default method.

            jjb Josh Bloch
            jjb Josh Bloch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: