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

Fix PrimitiveHashSet#iterator()#remove() to not rehash. Fixes #481 #484

Merged
merged 1 commit into from
Mar 19, 2018

Conversation

nikhilnanivadekar
Copy link
Contributor

No description provided.

…#481

Signed-off-by: Nikhil Nanivadekar <nikhil.nanivadekar@gs.com>
@gs-rezaem
Copy link
Contributor

LGTM 👍
This bug is serious enough that it must be backported to 7.x and 8.x

@gs-rezaem gs-rezaem merged commit fb86289 into eclipse:master Mar 19, 2018
@nikhilnanivadekar
Copy link
Contributor Author

I will create service releases for 7.x and 8.x. The service releases can be pushed anytime, so we can push them sooner than April 18.

@@ -1610,7 +1615,7 @@ public class <name>HashSet extends Abstract<name>Set implements Mutable<name>Set
{
removeValue = <name>HashSet.this.table[this.position - 1];
}
<name>HashSet.this.remove(removeValue);
<name>HashSet.this.remove(removeValue, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is good enough to fix the bug, I think there's a better implementation that we should add to the backlog.

We should basically inline the call to remove here, removing the call to rehash, and directly mutating the backing table. When we delegate to remove(), we'll be calling probe() again. We already know the position in the table, because we're iterating through positions and have the position field.

This would also be more consistent with UnifiedSet.

This MR doesn't seem to address the same bug in primitive maps, where they delegate to removeKey and rehash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a rehash in the maps. I checked 7.x, 8.x and 9.x

@motlin
Copy link
Contributor

motlin commented Mar 19, 2018 via email

@nikhilnanivadekar
Copy link
Contributor Author

Last night I had verified all Maps, Sets and Bags. Only primitiveSets has this issue.
Looking at the history it was added at a part of GS Collections [GSCOLLECT-1086]
goldmansachs/gs-collections@590786f#diff-e9eedad3e71045072ffec0aac02aa241R368

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 this pull request may close these issues.

None yet

3 participants