java-photoslibrary icon indicating copy to clipboard operation
java-photoslibrary copied to clipboard

Impossible to interrupt a long-running media item upload if invoked via blocking method

Open ylexus opened this issue 3 years ago • 0 comments

As per https://github.com/google/java-photoslibrary/issues/30#issuecomment-904352898, I can confirm that interrupting the upload via interrupting the thread blocked on client.uploadMediaItemCallable().futureCall(uploadRequest).get() works. However, as before, both client.uploadMediaItem() and client.uploadMediaItemCallable().call(uploadRequest) block uninterruptibly, because ApiExceptions.callAndTranslateApiException calls Futures.getUnchecked(future), which blocks uninterruptibly by design.

I don't know in which situation one would ever want to block uninterruptibly to be honest. It's a road to unresponsive apps, leaking threads etc. Also, the behaviour should be symmetrical regardless of how you invoke the API. At the very least, the interrupt behaviour must be documented.

ylexus avatar Oct 10 '21 17:10 ylexus