Skip to content

Commit

Permalink
Ensure that restarted request use the updated model when failed/cance…
Browse files Browse the repository at this point in the history
…led as it can contains data to help the request to succeed. (#2293)
  • Loading branch information
Tolriq authored and sjudd committed Aug 30, 2017
1 parent 9e9ce00 commit 0a44cf6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/src/main/java/com/bumptech/glide/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,15 @@ public <Y extends Target<TranscodeType>> Y into(@NonNull Y target) {
Request request = buildRequest(target);

Request previous = target.getRequest();
if (request.isEquivalentTo(previous)) {
// When request was failed or cancelled, be sure to use the updated model as it can contains
// unexposed data that could help the request to succeed on restart.
// See https://github.com/bumptech/glide/issues/2270
if (request.isEquivalentTo(previous)
&& (Preconditions.checkNotNull(previous).isComplete()
|| Preconditions.checkNotNull(previous).isRunning())) {
request.recycle();
// If the request is completed, beginning again will ensure the result is re-delivered,
// triggering RequestListeners and Targets. If the request is failed, beginning again will
// restart the request, giving it another chance to complete. If the request is already
// triggering RequestListeners and Targets. If the request is already
// running, we can let it continue running without interruption.
if (!Preconditions.checkNotNull(previous).isRunning()) {
previous.begin();
Expand Down

0 comments on commit 0a44cf6

Please sign in to comment.