googleapis / googleapis/google-cloud-java

[sdk-platform-java] ApiExceptions.callAndTranslateApiException should be interruptible

Đang mở
#12,508 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
priority: p2 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ả

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?)

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.