JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-560  -  org.jppf.utils.collections.ConcurrentHashSet.add() return value does not follow java.util.Set API
Posted Nov 18, 2018 - updated Nov 19, 2018
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Ray Tordoff
  • Owned by
    Not owned by anyone
  • Category
    Core
  • Resolution
    RESOLVED
  • Priority
    Low
  • Reproducability
    Always
  • Severity
    Low
  • Targetted for
    icon_milestones.png JPPF 5.2.10
Issue description
The org.jppf.utils.collections.ConcurrentHashSet add() method does not follow the java.util.Set API which states:

Returns:
true if this set did not already contain the specified element


The ConcurentHashSet implementation is doing the opposite and returning false when the Set does not already contain the element, and returns true when the Set already contains the item being added.
Steps to reproduce this issue
Set<Integer> set = new ConcurrentHashSet<>();
    boolean result = set.add(5); // result = false, expected = true
    boolean result2 = set.add(5); // result = true, expected = false

#10
Comment posted by
 lolo4j
Nov 19, 10:29
Fixed in master and branches 5.1, 5.2 and 6.0