From b1b36d32beeeb645c139f88259a2cfbbc9fb5743 Mon Sep 17 00:00:00 2001 From: Pollizzio Date: Tue, 22 Sep 2015 11:36:54 +0200 Subject: [PATCH] Original request in Retry Policy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing the request object to ‘retry’ method for Retry Policy classes. Given an opportunity to handle an error-retry custom policy with a request.setRedirectUrl() --- src/main/java/com/android/volley/DefaultRetryPolicy.java | 2 +- src/main/java/com/android/volley/RetryPolicy.java | 3 ++- src/main/java/com/android/volley/toolbox/BasicNetwork.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/android/volley/DefaultRetryPolicy.java b/src/main/java/com/android/volley/DefaultRetryPolicy.java index b6283f50..516998c1 100644 --- a/src/main/java/com/android/volley/DefaultRetryPolicy.java +++ b/src/main/java/com/android/volley/DefaultRetryPolicy.java @@ -89,7 +89,7 @@ public float getBackoffMultiplier() { * @param error The error code of the last attempt. */ @Override - public void retry(VolleyError error) throws VolleyError { + public void retry(VolleyError error, Request request) throws VolleyError { mCurrentRetryCount++; mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier); if (!hasAttemptRemaining()) { diff --git a/src/main/java/com/android/volley/RetryPolicy.java b/src/main/java/com/android/volley/RetryPolicy.java index 0dd198b2..cc801107 100644 --- a/src/main/java/com/android/volley/RetryPolicy.java +++ b/src/main/java/com/android/volley/RetryPolicy.java @@ -34,8 +34,9 @@ public interface RetryPolicy { /** * Prepares for the next retry by applying a backoff to the timeout. * @param error The error code of the last attempt. + * @param request The request that caused the retry. * @throws VolleyError In the event that the retry could not be performed (for example if we * ran out of attempts), the passed in error is thrown. */ - public void retry(VolleyError error) throws VolleyError; + public void retry(VolleyError error, Request request) throws VolleyError; } diff --git a/src/main/java/com/android/volley/toolbox/BasicNetwork.java b/src/main/java/com/android/volley/toolbox/BasicNetwork.java index 4f1df871..c1e492fc 100644 --- a/src/main/java/com/android/volley/toolbox/BasicNetwork.java +++ b/src/main/java/com/android/volley/toolbox/BasicNetwork.java @@ -209,7 +209,7 @@ private static void attemptRetryOnException(String logPrefix, Request request int oldTimeout = request.getTimeoutMs(); try { - retryPolicy.retry(exception); + retryPolicy.retry(exception, request); } catch (VolleyError e) { request.addMarker( String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));