[ISSUE #10860] Make DefaultPromise.get wait for completion - #11188
Open
beautyarbutin wants to merge 1 commit into
Open
beautyarbutin wants to merge 1 commit into
beautyarbutin wants to merge 1 commit into
Conversation
RockteMQ-AI
reviewed
Sep 21, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Summary
Fixes DefaultPromise.get() to properly block until the promise completes, instead of returning null immediately. Also fixes spurious wakeup handling, narrows exception catch to InterruptedException, restores the thread interrupt flag, and removes a redundant notifyListeners() call in getValueOrThrowable().
Findings
- [Critical] The original
get()returningresultimmediately violated the OpenMessagingPromisecontract. Callers expecting blocking behavior would silently getnull. Good fix. - [Warning] Removing
notifyListeners()fromgetValueOrThrowable()changes behavior — listeners are now only notified via the completion path (set/setFailure). The testtestGetDoesNotNotifyListenerAgainconfirms this is intentional (avoids double notification), but worth verifying that no caller depends ongetValueOrThrowable()triggering listener notification. - [Info] The
while (isDoing())loop correctly handles spurious wakeups. The interrupt handling restores the thread interrupt flag viaThread.currentThread().interrupt(), which is the correct Java idiom.
Overall
Well-implemented fix with comprehensive test coverage (waiting, failure propagation, interrupt handling, listener deduplication). LGTM.
Automated review by RockteMQ-AI
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()returned the current result immediately, so a pending promise could returnnullinstead of waiting for completion as required by the OpenMessaging API contract.This change makes
get()delegate to the indefinite-wait path, uses a state loop to handle spurious wakeups, and restores the thread interrupt flag when an interrupted wait is cancelled. It also removes listener notification from the read path so listeners remain notified exactly once by promise completion or cancellation.Tests cover waiting for completion, failure propagation, interrupted waits, and exactly-once listener notification.
How Did You Test This Change?
Before the implementation change, the new blocking test failed because the getter thread terminated instead of entering the waiting state.
mvn -pl openmessaging -am -DskipITs -Dtest=DefaultPromiseTest -Dsurefire.failIfNoSpecifiedTests=false testResult: 13 tests passed, Checkstyle reported 0 violations, and SpotBugs reported no errors or warnings.