[ISSUE #10860] Make DefaultPromise.get wait for completion - #10865
Open
yuluo-yx wants to merge 1 commit into
Open
[ISSUE #10860] Make DefaultPromise.get wait for completion#10865yuluo-yx wants to merge 1 commit into
yuluo-yx wants to merge 1 commit into
Conversation
RockteMQ-AI
approved these changes
Aug 8, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Summary
Fixes a critical correctness issue where DefaultPromise.get() returned immediately without waiting for the promise to complete. Also fixes spurious wakeup handling and interrupt flag restoration.
Analysis
- Correctness ✅ — The old
get()returningresultdirectly (which isnullbefore completion) defeats the entire purpose of a Promise. The fix to delegate toget(0)with proper wait semantics is correct. Thewhile (isDoing())loop handles spurious wakeups. Thecatch (InterruptedException)withThread.currentThread().interrupt()properly restores the interrupt flag. - Tests ✅ — Three regression tests covering: basic wait-for-completion, timeout behavior, and the interrupted-flag restoration.
- Compatibility
⚠️ — This is a behavioral change: callers ofget()that relied on the old non-blocking behavior will now block. However, the old behavior was clearly a bug (a Promise that doesn't wait is useless), so this is the correct fix.
LGTM.
Automated review by github-manager-bot
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10865 +/- ##
=============================================
- Coverage 48.39% 48.29% -0.10%
+ Complexity 13562 13535 -27
=============================================
Files 1380 1380
Lines 101165 101167 +2
Branches 13127 13128 +1
=============================================
- Hits 48962 48862 -100
- Misses 46233 46318 +85
- Partials 5970 5987 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which Issue(s) This PR Fixes
Brief Description
The no-argument OpenMessaging
DefaultPromise.get()now uses the existing wait path instead of returning a pendingnullresult. The indefinite wait uses a state loop to handle spurious wakeups and restores the interrupt flag when interrupted.Reading a completed value no longer notifies listeners again. Regression tests cover waiting for completion, failure propagation, and single listener notification.
How Did You Test This Change?
mise exec java@temurin-17.0.19+10 -- mvn -pl openmessaging -am -Dtest=DefaultPromiseTest -Dsurefire.failIfNoSpecifiedTests=false -Dspotbugs.skip=true testBUILD SUCCESS; 12 tests, 0 failures, 0 errors, 0 skipped.