This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 268299 - HashSet adding equal integer arrays
Summary: HashSet adding equal integer arrays
Status: NEW
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.1
Hardware: PC Windows 10
: P3 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-30 23:55 UTC by henri127
Modified: 2016-09-30 23:55 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description henri127 2016-09-30 23:55:53 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_72
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.72-b15

Reproducibility: Happens every time

STEPS:
  * Open dialog Foo
  * Click on button "Click me"

ACTUAL:
  nothing happens

EXPECTED:
  message pops up


Assume:

HashSet<int[]> set = new HashSet();

for (int i = 0; i < 100; i++) {
	int[] array = new int[1];
	array[0] = i%50;
	set.add(array);
}

This will add 100 one size long integer arrays to set which makes set have more than 50 times the same int[] array.

The documentation quotes:

//------------documentation
public boolean add(E e)

Adds the specified element to this set if it is not already present. More formally, adds the specified element e to this set if this set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set already contains the element, the call leaves the set unchanged and returns false.

Specified by:
    add in interface Collection<E>
Specified by:
    add in interface Set<E>
Overrides:
    add in class AbstractCollection<E>
Parameters:
    e - element to be added to this set
Returns:
    true if this set did not already contain the specified element

//-------end documentatio