Run CompletableResultCode completion action outside the lock - #8773
Run CompletableResultCode completion action outside the lock#8773amit306 wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8773 +/- ##
=========================================
Coverage 91.29% 91.29%
- Complexity 10498 10523 +25
=========================================
Files 1006 1007 +1
Lines 28338 28397 +59
Branches 3581 3594 +13
=========================================
+ Hits 25870 25926 +56
- Misses 1675 1676 +1
- Partials 793 795 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-06 22:12 UTC Review the latest changes. Status above doesn't look right?
|
28f8686 to
ee78eb3
Compare
We should do this, plus logging for all exceptions. Also, let's catch Exception, not Throwable. That will mean that errors (i.e. Throwables which are not Exceptions) bubble up and violate the "allOf" completion guarantee. But this seems fine and defensible. Also, your PR description is too verbose. The key details are watered down by the noise of details like which specific test cases were added, which is self explanatory from the code. Less is more. I recommend writing PR descriptions/comments yourself, rather than relying on AI. |
Fixes open-telemetry#8771 Signed-off-by: amit306 <amit.anand0312@gmail.com>
ee78eb3 to
4afc49d
Compare
thanks @jack-berg for comment. I updated the code and description. Please check |
Fixes #8771
Problem
CompletableResultCode#succeed and failInternal run completion actions while holding a lock. This can cause a deadlock if two actions try to complete each other. Also, if an action throws an exception, the remaining actions are skipped and the result may never complete.
Solution
Both methods now use a shared complete method. It updates the result and copies the actions while holding the lock, then releases the lock before running them. runActions logs each exception, continues running the remaining actions, and rethrows the first exception at the end. whenComplete also uses runActions when the result is already complete.