Skip to content

Commit bc4835f

Browse files
committed
Fix ConcurrentModificationException in Dispatcher.performSubmit()
Fixes square#641
1 parent 1264135 commit bc4835f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

picasso/src/main/java/com/squareup/picasso/Dispatcher.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ void dispatchAirplaneModeChange(boolean airplaneMode) {
161161
}
162162

163163
void performSubmit(Action action) {
164+
performSubmit(action, true);
165+
}
166+
167+
void performSubmit(Action action, boolean dismissFailed) {
164168
if (pausedTags.contains(action.getTag())) {
165169
pausedActions.put(action.getTarget(), action);
166170
if (action.getPicasso().loggingEnabled) {
@@ -186,7 +190,9 @@ void performSubmit(Action action) {
186190
hunter = forRequest(action.getPicasso(), this, cache, stats, action);
187191
hunter.future = service.submit(hunter);
188192
hunterMap.put(action.getKey(), hunter);
189-
failedActions.remove(action.getTarget());
193+
if (dismissFailed) {
194+
failedActions.remove(action.getTarget());
195+
}
190196

191197
if (action.getPicasso().loggingEnabled) {
192198
log(OWNER_DISPATCHER, VERB_ENQUEUED, action.request.logId());
@@ -394,7 +400,7 @@ private void flushFailedActions() {
394400
if (action.getPicasso().loggingEnabled) {
395401
log(OWNER_DISPATCHER, VERB_REPLAYING, action.getRequest().logId());
396402
}
397-
performSubmit(action);
403+
performSubmit(action, false);
398404
}
399405
}
400406
}

0 commit comments

Comments
 (0)