Pub/Sub streaming pull swallows Throwable
s that are not Exception
s
#1156
Labels
api: pubsub
Issues related to the googleapis/java-pubsub API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
This issue is a general case of the one in GoogleCloudPlatform/spring-cloud-gcp#1103. When user message processing results in a non-
Exception
Throwable
(the two common usecases being assertion errors and system errors such asOutOfMemoryError
), Pub/Sub client library effectively silently ignores the failure.While the best practice is to avoid catching
Throwable
, in case of message processing it needs to be done -- the user application needs to have useful troubleshooting logs, and ideally the message ought to get nacked, as well. Of course, nacking with something likeOutOfMemoryError
won't reliably happen, but it's still worth an attempt.Current behavior
Currently when user message processing code throws an
Error
, thisMessageDispatcher
code will pass the error on without catching, as the catch clause only applies toException
. However,deliverMessageTask
is a simple runnable that runs on a GAX thread. When the error bubbles up, the thread is returned to the thread pool.Desired behavior
The catch block in
MessageDispatcher
should apply to anyThrowable
, so thatackReplySettableApiFuture.setException(e);
can get set and processed as an error.Environment details
Steps to reproduce
A slightly modified code sample from docs demonstrates the issue:
The text was updated successfully, but these errors were encountered: