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

Update IslandLevelCalculator.java #314

Merged
merged 1 commit into from
May 31, 2024
Merged

Update IslandLevelCalculator.java #314

merged 1 commit into from
May 31, 2024

Conversation

tastybento
Copy link
Member

@tastybento tastybento commented May 31, 2024

Fix for occasional errors likely due to the use of the remove() method within a lambda expression inside the thenAccept method. This lambda expression is executed asynchronously, which means that the iterator may not be in a consistent state when remove() is called.

Since thenAccept runs asynchronously, the iteration over stackedBlocks may continue before the lambda is executed, leading to an inconsistent state when it.remove() is called.

To fix this issue, you should collect the elements to be removed in a separate collection and remove them after the iteration is complete.

In this version, the elements to be removed are collected in a separate List<Location> toRemove, which is synchronized to handle concurrent access. After the iteration is complete and all asynchronous tasks have been executed, the collected elements are removed from stackedBlocks.

Fix for occasional errors likely due to the use of the remove() method within a lambda expression inside the thenAccept method. This lambda expression is executed asynchronously, which means that the iterator may not be in a consistent state when remove() is called.
Copy link

sonarcloud bot commented May 31, 2024

@tastybento tastybento merged commit 0bb6eac into develop May 31, 2024
2 checks passed
@tastybento tastybento deleted the tastybento-patch-1 branch May 31, 2024 20:12
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.

1 participant