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

Issue1202 boekabart #1645

Merged
merged 1 commit into from
Jan 18, 2016
Merged

Conversation

boekabart
Copy link
Contributor

This fixes #1202 which was caused by Remove sometimes returning an unbalanced tree. This happened in after the 'core' remove, node X became unbalanced, and either X.L.R was higher than X.L.L or X.R.L was higher than X.R.R .

This has been reproduced in 2 unit tests.

Mostly this would not lead to a problem: a next remove or add would fix it, but in some cases (haven't been able to reproduce in a Unit Test, though) doing adds close to this tree (not to the tree itself!) would lead to a NullReferenceException when Rotating the now-unbalanced tree.

The fix is trivial: DoubleRotate should be done when the tree-after-remove is left (resp right) heavy - not only when it's left/right imbalanced. The helper functions were incorrectly named.

@boekabart
Copy link
Contributor Author

Is that a racy test or should I look into it?

@Aaronontheweb
Copy link
Member

The test that failed initially might have been one of the racy Akka.Persistence tests that we know about - so no worries.

However, could you please squash and rebase your commits? The steps for doing this are covered inside contributing.md.

Changed fix for better consistency/comparability with the code just above

Added unit test for 2 types of removals that used to return an unbalanced tree.
@rogeralsing
Copy link
Contributor

Merging this, thanks!

rogeralsing added a commit that referenced this pull request Jan 18, 2016
@rogeralsing rogeralsing merged commit b026bb9 into akkadotnet:dev Jan 18, 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 this pull request may close these issues.

NullReferenceException in Akka.Util.Internal.Collections.ImmutableAvlTreeBase`2.RotateLeft
4 participants