Utils.waitUntilReady should record the stack trace of the caller before rethrowing an exception #1797
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had a situation where one method in my code called a second, which called a third, which called
Watchable.watch
, and I thinkwatch
threw up an exception (in this case due to an RBAC mistake) which was caught ultimately in my first method (according to the method name recorded byjava.util.logging
)…but it was hard to tell for sure since the stack trace includingwatch
was nowhere to be seen:Poking around, my guess is that the problem is that
Utils.waitUntilReady
is taking this exception thrown and caught in some thread pool and rethrowing it to its caller. Somehow the caller’s stack trace needs to be included.(Another idiom is to wrap the original exception in a new exception using
cause
, but that forces you to pick a type for the wrapper; usingaddSuppressed
avoids that issue.)I had hoped to test this change against the original reproduced problem; unfortunately I did not manage to compile this project, getting seemingly different puzzling errors from Maven or javac each time, like
or
or