[ISSUE #10747] Fix InvokeCallback completion order - #10753
Open
ai-yang wants to merge 1 commit into
Open
Conversation
Signed-off-by: Rui <1685901819@qq.com>
ai-yang
marked this pull request as ready for review
August 2, 2026 14:22
RockteMQ-AI
reviewed
Aug 2, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Restructures invokeAsyncImpl to guarantee that outcome callbacks (operationSucceed/operationFail) are always invoked before the completion callback (operationComplete), and wraps both in try-catch to prevent one failure from blocking the other.
Findings
- [Info]
NettyRemotingAbstract.java:680-707— The singlewhenCompletehandler replaces the previousthenAccept/exceptionallychain, eliminating the ordering ambiguity. Outcome callback is now explicitly called first, then completion callback. - [Info] The try-catch around each callback invocation ensures that a misbehaving callback cannot prevent the other from executing. This is important for cleanup paths.
- [Info]
NettyRemotingClientTest.java— Tests now verify callback ordering withInOrderand cover the case where a callback throws. The newtestInvokeAsyncCompleteFailureDoesNotInvokeFailureCallbacktest validates thatoperationFailreceives the correct exception instance.
Suggestions
- Consider adding a brief comment in the
whenCompletehandler explaining why outcome must precede completion (contract: callers may depend on outcome state inoperationComplete).
Automated review by github-manager-bot
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
invokeAsyncImpl()chainedwhenComplete,thenAccept, andexceptionally. This causedoperationCompleteto run beforeoperationSucceedoroperationFail, contrary to theInvokeCallbackcontract, and allowed exceptions thrown by callback methods to flow into the invocation-failure stage.The fix handles the original invocation result in one terminal
whenCompletecallback:operationSucceedoroperationFailbeforeoperationComplete;finally, including when the outcome callback throws.Callback exceptions are caught and logged locally because
invokeAsyncImpl()returnsvoidand does not expose the dependent completion stage. This guarantees thatoperationCompletestill runs and prevents callback failures from being misclassified as remoting invocation failures.How Did You Test This Change?
develop: the deterministic callback-order regression failed in 5/5 isolated JDK 8 Maven processes.git diff --check: passed.