fix: feign RepeatedCollectManager depth leak causing record miss (#587)#622
Merged
zwobill merged 1 commit intoJul 16, 2026
Merged
Conversation
…xtest#587) onEnter unconditionally called RepeatedCollectManager.enter() but onExit skipped exitAndValidate() when a mock result was returned, so CallDepth kept growing across replay-hit requests. Once depth passed 1, subsequent record attempts on the same thread saw exitAndValidate()==false and were silently dropped (issue arextest#587 reports depth reaching 9 while normal is 4). - move outermost check (validate()) before enter() so nested http clients (e.g. Feign -> Apache) skip inner replay and avoid request body double consumption - call exitAndValidate() unconditionally in onExit to keep enter/exit balanced regardless of mock hit - update tests to cover the nested-call skip path
DZQOX
force-pushed
the
fix/587-feign-repeatedcollect-symmetry
branch
from
July 16, 2026 05:19
48e0eee to
794f6c9
Compare
zwobill
enabled auto-merge (squash)
July 16, 2026 05:55
|
mengqcc
approved these changes
Jul 16, 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
Fix #587 — under mixed record/replay traffic on the same thread, some requests silently fail to record (issue reports ~10% failure rate; user observed
CallDepthreaching 9 while a normal call chain tops out at 4). Root cause is unbalancedRepeatedCollectManager.enter()/exitAndValidate()in the Feign advice.Root cause
In
FeignClientInstrumentation.ExecuteAdvice:onEntercallsRepeatedCollectManager.enter()unconditionally whenneedRecordOrReplay()onExitreturns early inside themockResult != null && notIgnoreMockResult()branch, without callingexitAndValidate()Every replay-hit request therefore leaks
+1on the thread-localCallDepth. Once depth passes 1, subsequent record attempts on the same thread seeexitAndValidate() == falseand are dropped. This explains the "10% requests not recorded / depth up to 9" symptom in the issue.There's also a latent bug in the same code path: nested http clients (e.g. Feign wrapping Apache HttpClient via
feign-httpclient) both try to replay, and the inner client re-consumes the request body — leading to replay-match misses.Changes
FeignClientInstrumentation.java:enter()— captureboolean isOutermost = RepeatedCollectManager.validate()first, so a nested call detects it's inside an already-entered scope and skips its own replay.isOutermost— inner nested clients no longer double-consume the request body.exitAndValidate()called unconditionally at top ofonExit— mock hits now decrementCallDepthtoo, keeping enter/exit balanced. The savedisOutermostis used for the record gate.FeignClientInstrumentationTest.java:RepeatedCollectManager.validate()in the existing replay-path assertionTest plan
mvn -pl arex-instrumentation/httpclient/arex-httpclient-feign test— 12/12 pass