googleapis / googleapis/google-cloud-java

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

Open
#12,508 1 comment 0 reactions 0 assignees View on GitHub
priority: p2 type: feature request
Dominant language
Java
Stars
2.1k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
154

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.