googleapis / googleapis/google-cloud-java
[sdk-platform-java] ApiExceptions.callAndTranslateApiException should be interruptible
- 主要言語
- Java
- スター
- 2.1k
- フォーク
- 1.2k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 154
説明
ApiExceptions.callAndTranslateApiException is used to adapt async calls to sync calls. For example its used here:
https://github.com/googleapis/gapic-generator-java/blob/c23f981e2ac3c573bed51e725dc7061551179400/gax-java/gax/src/main/java/com/google/api/gax/rpc/UnaryCallable.java#L99-L101
To accomplish this callAndTranslateApiException uses guava's Futures.getUnchecked() function. This function will swallow/ignore thread interruptions, and continue to wait on the underlying future. This prevents end users from cancelling RPCs from a sync call convention. I think a much better approach would be to catch the interruption and cancel the underlying future and re-throw an error (maybe gax's CancelledException?)
コントリビューションガイド
評価
この issue はまだ評価されていません。