Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with cloned java.util.LinkedHashSet #46

Closed
antonu17 opened this issue Jan 6, 2016 · 0 comments · Fixed by #95
Closed

Working with cloned java.util.LinkedHashSet #46

antonu17 opened this issue Jan 6, 2016 · 0 comments · Fixed by #95

Comments

@antonu17
Copy link

antonu17 commented Jan 6, 2016

Create new LinkedHashSet and populate it with 2 objects.

Set<Object> set = new LinkedHashSet<>();
set.add(new Object());
set.add(new Object());

Then make deep clone of if

Cloner cloner = new Cloner();
Set<Object> clone = cloner.deepClone(set);

And finnaly pick the first item and try to check if cloned set contains it (or even remove it from there)

Object first = clone.toArray()[0];
clone.contains(first); // returns false
clone.remove(first);  // also returns false and leave set unchanged

PS.
It only affects java.util.LinkedHashSet, java.util.HashSet works well, as expected.

@antonu17 antonu17 changed the title Working with clonned java.util.LinkedHashSet Working with cloned java.util.LinkedHashSet Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant