Skip to content

Commit

Permalink
added over_query_limit to retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
markmcd committed Sep 15, 2014
1 parent 619a1e1 commit bf2f67a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/com/google/maps/internal/OkHttpPendingResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.maps.PendingResult;
import com.google.maps.errors.OverQueryLimitException;
import com.google.maps.model.AddressComponentType;
import com.google.maps.model.AddressType;
import com.google.maps.model.Distance;
Expand Down Expand Up @@ -222,9 +223,17 @@ private T parseResponse(OkHttpPendingResult<T, R> request, Response response) th
R resp = gson.fromJson(reader, responseClass);

if (resp.successful()) {
// Return successful responses
return resp.getResult();
} else {
throw resp.getError();
Exception e = resp.getError();
if (e instanceof OverQueryLimitException && cumulativeSleepTime < errorTimeOut) {
// Retry over_query_limit errors
return request.retry();
} else {
// Throw anything else, including OQLs if we've spent too much time retrying
throw e;
}
}
}

Expand Down

0 comments on commit bf2f67a

Please sign in to comment.