forked from google/volley
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix concurrent modification errors in ImageContainer.
ImageContainer#cancelRequest modifies data structures that are mutated without a lock on the main thread. Its parent class, ImageLoader, is documented as requiring that all access happen on the main thread, so strictly enforce that cancelRequest be called from the main thread as well. Outside of cancelRequest, the only uncontrolled caller is NetworkImageView#setImageUrl, which we also document/enforce as needing to be called from the main thread. Add @mainthread annotations and Javadoc clarifications as appropriate. Clarify that behavior on custom ResponseDeliveries is undefined. Fixes google#132
- Loading branch information
Showing
3 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.android.volley.toolbox; | ||
|
||
import android.os.Looper; | ||
|
||
final class Threads { | ||
private Threads() {} | ||
|
||
static void throwIfNotOnMainThread() { | ||
if (Looper.myLooper() != Looper.getMainLooper()) { | ||
throw new IllegalStateException("Must be invoked from the main thread."); | ||
} | ||
} | ||
} |