-
Notifications
You must be signed in to change notification settings - Fork 753
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
Exception: java.util.ConcurrentModificationException on 1.1.1-rc1 #205
Comments
do not modify the ArrayList when it is being traversed |
Assuming the line in question is indeed line 491 of ImageLoader.java: for (ImageContainer container : bir.mContainers) { then the issue would be something mutating mContainers during this iteration. This line of code always runs on the main thread (it is posted to a main thread handler). There are four other methods which mutate mContainers, but as far as I can tell, all of these are only called by methods which first invoke Threads.throwIfNotOnMainThread(), and so would throw a different failure if they were being called here on a different thread. There are thus only two possibilities I can think of:
I don't think this is a regression from older builds. Sounds like this was a one-off crash reported in the wild? Do you have more information (and ideally code) showing how you are using ImageLoader? |
https://stackoverflow.com/questions/35479128/volley-image-loader-concurrentmodificationexception seems to be a similar crash with sample code in the wild. |
We have a similar exception. |
CME is most often thrown from a single thread, despite the name, so that seems most likely here. These iterators are both in flight when a listener may be called on the same thread:
Maybe the problem can be avoided by switching to indexed loops:
Or copying to an array before iterating, depending on the desired behavior. The outer batchedResponses loop should also be protected from concurrent modification in the same way. An invoked listener might be able to reach:
|
I got this crash report on the latest build 1.1.1-rc1
Fatal Exception: java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
at com.android.volley.toolbox.ImageLoader$4.run(SourceFile:491)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5318)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
The text was updated successfully, but these errors were encountered: