Quantcast
Channel: Day to day stuff
Viewing all articles
Browse latest Browse all 83

Breaking a Java HashSet

$
0
0
Can it be? Set set1 = new HashSet(5); Set set2 = new HashSet(5); // add of bunch of strings to both sets assert set1.equals(set2) == false; Yes it can! We actually had this problem in an integration test. The cause was that the strings to one set were added concurrently. Interestingly, the sets seemed to be the same, when printed they contained the same strings, just in a different order (

Viewing all articles
Browse latest Browse all 83

Trending Articles