Skip to content

Commit

Permalink
Merge pull request square#680 from lucasr/issue641
Browse files Browse the repository at this point in the history
Fix ConcurrentModificationException in Dispatcher.performSubmit()
  • Loading branch information
JakeWharton committed Sep 29, 2014
2 parents 4b0e2b5 + bc4835f commit 4e52154
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions picasso/src/main/java/com/squareup/picasso/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ void dispatchAirplaneModeChange(boolean airplaneMode) {
}

void performSubmit(Action action) {
performSubmit(action, true);
}

void performSubmit(Action action, boolean dismissFailed) {
if (pausedTags.contains(action.getTag())) {
pausedActions.put(action.getTarget(), action);
if (action.getPicasso().loggingEnabled) {
Expand All @@ -186,7 +190,9 @@ void performSubmit(Action action) {
hunter = forRequest(action.getPicasso(), this, cache, stats, action);
hunter.future = service.submit(hunter);
hunterMap.put(action.getKey(), hunter);
failedActions.remove(action.getTarget());
if (dismissFailed) {
failedActions.remove(action.getTarget());
}

if (action.getPicasso().loggingEnabled) {
log(OWNER_DISPATCHER, VERB_ENQUEUED, action.request.logId());
Expand Down Expand Up @@ -394,7 +400,7 @@ private void flushFailedActions() {
if (action.getPicasso().loggingEnabled) {
log(OWNER_DISPATCHER, VERB_REPLAYING, action.getRequest().logId());
}
performSubmit(action);
performSubmit(action, false);
}
}
}
Expand Down

0 comments on commit 4e52154

Please sign in to comment.