JDK-8358282 : Javadoc for ConcurrentSkipListSet.add(E e) is wrong
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 8,25
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2025-05-31
  • Updated: 2025-06-02
Description
A DESCRIPTION OF THE PROBLEM :
The Javadoc for ConcurrentSkipListSet's add(E e) method states that the method "adds the specified element e to this set if the set contains no element e2 such that e.equals(e2)". This is not true, since it actually determines equality using natural ordering (i.e. a Comparable's compareTo method), unless a custom comparator is defined. This can lead to elements not being added because they were unexpectedly determined to be equal to another element.



Comments
Impact -> M (Somewhere in-between the extremes) Likelihood -> L (Only documentation changes) Workaround -> M (Somewhere in-between the extremes) Priority -> P4
02-06-2025

The description in questions can be found at: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#add-E- https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/concurrent/ConcurrentSkipListSet.html#add(E)
02-06-2025