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

ConcurrentSkipListMap.clone() shares size variable between original and clone

    Details

      Backports

        Description

        A bug has been found where cloning a ConcurrentSkipListMap doubles the "size" return value in both original and clone, as a result of the two maps sharing the same size variable (which also causes other problems).

        The contents of the maps themselves does not appear to be affected. Clone a map of size 3 and you still have 3 elements in each map post-clone, even though the size() method is not returning 6 for both.

        It seems this was caused by the creation of the "adder" variable introduced in JDK-8186226, for JDK10, to track the array size. Since adder is an Object, a shallow clone results in two objects sharing the same variable.

        Since the clone process already wipes other variables, it seems a good idea to do the same here.

        Code fix and test available.

        Webrev for jdk/jdk : http://cr.openjdk.java.net/~afarley/8222930.0/jdk13/webrev/

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  afarley Adam Farley
                  Reporter:
                  afarley Adam Farley
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 day
                    1d
                    Remaining:
                    Remaining Estimate - 2 hours
                    2h
                    Logged:
                    Time Spent - Not Specified Time Not Required
                    Not Specified