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/
|