Skip to content

Commit c5049a7

Browse files
authored
Revert "Remove deprecated BackOffPolicy interface (#506)" (#521)
This reverts commit d5effe8.
1 parent 710117e commit c5049a7

File tree

7 files changed

+944
-23
lines changed

7 files changed

+944
-23
lines changed

clirr-ignored-differences.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,4 @@
77
<differenceType>8001</differenceType>
88
<className>com/google/api/client/repackaged/**</className>
99
</difference>
10-
<difference>
11-
<differenceType>7002</differenceType>
12-
<className>com/google/api/client/http/HttpRequest</className>
13-
<method>com.google.api.client.http.BackOffPolicy getBackOffPolicy()</method>
14-
</difference>
15-
<difference>
16-
<differenceType>7002</differenceType>
17-
<className>com/google/api/client/http/HttpRequest</className>
18-
<method>com.google.api.client.http.HttpRequest setBackOffPolicy(com.google.api.client.http.BackOffPolicy)</method>
19-
</difference>
20-
<difference>
21-
<differenceType>8001</differenceType>
22-
<className>com/google/api/client/http/BackOffPolicy</className>
23-
</difference>
24-
<difference>
25-
<differenceType>8001</differenceType>
26-
<className>com/google/api/client/http/ExponentialBackOffPolicy*</className>
27-
</difference>
2810
</differences>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2011 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.google.api.client.http;
16+
17+
import com.google.api.client.util.Beta;
18+
19+
import java.io.IOException;
20+
21+
/**
22+
* {@link Beta} <br/>
23+
* Strategy interface to control back off between retry attempts.
24+
*
25+
* @since 1.7
26+
* @author Ravi Mistry
27+
* @deprecated (scheduled to be removed in 1.18) Use {@link HttpBackOffUnsuccessfulResponseHandler}
28+
* instead.
29+
*/
30+
@Deprecated
31+
@Beta
32+
public interface BackOffPolicy {
33+
34+
/**
35+
* Value indicating that no more retries should be made, see {@link #getNextBackOffMillis()}.
36+
*/
37+
public static final long STOP = -1L;
38+
39+
/**
40+
* Determines if back off is required based on the specified status code.
41+
*
42+
* <p>
43+
* Implementations may want to back off on server or product-specific errors.
44+
* </p>
45+
*
46+
* @param statusCode HTTP status code
47+
*/
48+
public boolean isBackOffRequired(int statusCode);
49+
50+
/**
51+
* Reset Back off counters (if any) in an implementation-specific fashion.
52+
*/
53+
public void reset();
54+
55+
/**
56+
* Gets the number of milliseconds to wait before retrying an HTTP request. If {@link #STOP} is
57+
* returned, no retries should be made.
58+
*
59+
* This method should be used as follows:
60+
*
61+
* <pre>
62+
* long backoffTime = backoffPolicy.getNextBackoffMs();
63+
* if (backoffTime == BackoffPolicy.STOP) {
64+
* // Stop retrying.
65+
* } else {
66+
* // Retry after backoffTime.
67+
* }
68+
*</pre>
69+
*
70+
* @return the number of milliseconds to wait when backing off requests, or {@link #STOP} if no
71+
* more retries should be made
72+
*/
73+
public long getNextBackOffMillis() throws IOException;
74+
}

0 commit comments

Comments
 (0)