File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
sigstore-java/src/main/java/dev/sigstore/http Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package dev .sigstore .http ;
17
17
18
+ import com .google .api .client .http .HttpBackOffIOExceptionHandler ;
18
19
import com .google .api .client .http .HttpRequestFactory ;
19
20
import com .google .api .client .http .HttpTransport ;
20
21
import com .google .api .client .http .apache .v2 .ApacheHttpTransport ;
22
+ import com .google .api .client .util .ExponentialBackOff ;
21
23
import java .io .IOException ;
22
24
import org .apache .http .conn .ssl .NoopHostnameVerifier ;
23
25
import org .apache .http .impl .client .HttpClientBuilder ;
@@ -38,15 +40,18 @@ public static HttpTransport newHttpTransport(HttpParams httpParams) {
38
40
return new ApacheHttpTransport (hcb .build ());
39
41
}
40
42
41
- /** Create a new get requests with the httpParams applied and exponential backoff retries. */
43
+ /** Create a new get requests with the httpParams applied and retries. */
42
44
public static HttpRequestFactory newRequestFactory (HttpParams httpParams ) throws IOException {
43
45
return HttpClients .newHttpTransport (httpParams )
44
46
.createRequestFactory (
45
47
request -> {
46
48
request .setConnectTimeout (httpParams .getTimeout () * 1000 );
47
49
request .setReadTimeout (httpParams .getTimeout () * 1000 );
50
+ request .setNumberOfRetries (3 ); // arbitrarily selected number of retries
48
51
request .setUnsuccessfulResponseHandler (
49
52
UnsuccessfulResponseHandler .newUnsuccessfulResponseHandler ());
53
+ request .setIOExceptionHandler (
54
+ new HttpBackOffIOExceptionHandler (new ExponentialBackOff ()));
50
55
});
51
56
}
52
57
}
You can’t perform that action at this time.
0 commit comments