googleapis / googleapis/google-cloud-java

[google-auth-library-java] How to set a timeout for GoogleCredentials?

Đang mở
#12,615 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
priority: p3 type: feature request
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

`GoogleCredentials` can be initialized with an optional `HttpTransportFactory`. But this doesn't provide any means of setting the connection and read timeout for the HTTP requests made by the credentials implementation. Is there a way to set these timeout values for `GoogleCredentials`?

More context: In the Google HTTP client, the recommended way to set timeouts is via an `HttpRequestInitializer` that gets passed into the `HttpRequestFactory`.

```
myTransport.createRequestFactory(new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
request.setConnectTimeout(10000);
request.setReadTimeout(10000);
}
});
```

But currently there appears to be no way to specify a request initializer for `GoogleCredentials`. As a result, there's no simple way to configure the timeouts for the HTTP requests made by this implementation.

This is a somewhat critical issue, since `GoogleCredentials` get invoked before any other HTTP requests are made by the client. The default timeout settings of `GoogleCredentials` essentially mask and override any timeout values set in the client.

```
myTransport.createRequestFactory(new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
credentials.initialize(request);
request.setConnectTimeout(10000);
request.setReadTimeout(10000);
}
});
```

In the above example you expect requests to timeout after 10 seconds. But because credentials are in the initializer chain, it won't timeout until 60s (the default).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.