[CXF-9204] Fix NPE in ClientImpl when failover retry fails#2939
Merged
gnodet merged 2 commits intoapache:mainfrom Mar 11, 2026
Merged
[CXF-9204] Fix NPE in ClientImpl when failover retry fails#2939gnodet merged 2 commits intoapache:mainfrom
gnodet merged 2 commits intoapache:mainfrom
Conversation
…ails When a failover retry throws an exception, FailoverTargetSelector.performFailover unconditionally clears the exception from the outMessage (line 198) before the retry, but the catch block only conditionally restores it (checking if the content is non-null). Since it was already cleared, the condition is always false, so the exception is never restored. This causes the fault observer in ClientImpl.doInvoke to enter the "handle success" path where it tries to read the inbound message (which is null after exchange.clear()), resulting in a NullPointerException. Fix: unconditionally restore the previous exception in the catch block of performFailover. Also add a defensive null check for the inbound message in ClientImpl's fault observer to prevent NPE even if other code paths lead to a null inbound message after failover. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
reta
reviewed
Mar 10, 2026
Per review feedback: with the root cause fix in FailoverTargetSelector (unconditional exception restoration), inMsg should always be available in this code path. Keep it clean.
reta
approved these changes
Mar 10, 2026
ffang
approved these changes
Mar 10, 2026
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.
Summary
FailoverTargetSelector.performFailover(), the exception onoutMessageis unconditionally cleared before the retry attempt (outMessage.setContent(Exception.class, null)), but thecatchblock only conditionally restores it (if (outMessage.getContent(Exception.class) != null)). Since the exception was already cleared, this condition is alwaysfalse, so the exception is never restored when a retry fails.ClientImpl.doInvoke()sees no exception on the message and enters the "handle the right response" path, whereexchange.getInMessage()returnsnull(the exchange was cleared byexchange.clear()), causing aNullPointerException.catchblock ofperformFailover(). Also add a defensive null check forinMsginClientImpl's fault observer.Changes
FailoverTargetSelector.performFailover()— always restore the original exception when the retry failsClientImpl.doInvoke()fault observer — add null guard forinMsgafter failoverFailoverTargetSelectorTest— verifies exception restoration on failed retryTest plan
FailoverTargetSelectorTest.testExceptionRestoredOnFailedRetrypasses with fix, fails withoutcoreendpoint tests passFailoverTest(manual verification recommended)FailOverFeatureTest.testPojo()should now pass (the original reproducer)🤖 Generated with Claude Code