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 the java.util.ConcurrentModificationException #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coffeeplanter
Copy link

Fix the following error when screen rotate while quad tree is building:

java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.next(ArrayList.java:831)
at net.sharewire.googlemapsclustering.ClusterManager$QuadTreeTask.doInBackground(ClusterManager.java:241)
at net.sharewire.googlemapsclustering.ClusterManager$QuadTreeTask.doInBackground(ClusterManager.java:227)

@makovkastar
Copy link
Member

Thank you, sorry for the delay. I will take a look asap.

@makovkastar makovkastar added the bug label Mar 6, 2018
@makovkastar
Copy link
Member

I cannot reproduce this issue in the sample project. It seems that in your code you are trying to remove items from the list you passed to ClusterManager.setItems(...). I'm thinking whether there should be a fix in the library or not.

@coffeeplanter
Copy link
Author

coffeeplanter commented Mar 7, 2018

You can check my test project: https://github.com/coffeeplanter/MapTest
I've included there your library as modified source code. Try to change back there the code from this pull request, install apk, and rotate the device several times during first data downloading. I think, you'll get the exception. Please note that after download completion data are loaded from the local database, and this exception is not thrown.
I was not trying to remove items manually. The current behaviour is caused by the library itself.

@Merrrrrid
Copy link

I also encountered this problem. I don’t do anything specific with clusters, I give all the guidance to the clusters to the library. This pull request must solve this problem.

@marekdef
Copy link

I am pretty sure that ConcurrentModification exception is caused by passing a mutable list to setItems.
The solution in this PR just hides the problem because if there is a modification of this list the indexes will be different - it's just a matter of luck what we get (I guess is pretty common to extend the list so we will get no crash but we will miss some markers).
I think in the project mentioned by @coffeeplanter we passed cachedPoints to onSucccess which is mutated by data download and that might be the reason.

Copy link

@hassaanjamil hassaanjamil left a comment

Choose a reason for hiding this comment

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

Sorry, for the comment. I am unable to delete it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants