Fix jedis-4.x-plugin double-stopping the span stack on Redis exceptions - #829
Merged
wu-sheng merged 1 commit intoSep 16, 2026
Merged
Conversation
AbstractConnectionInterceptor.handleMethodException() called ContextManager.stopSpan(span) explicitly, but afterMethod() always runs afterwards too (InstMethodsInter invokes it in a finally block on every path, including exceptions) and stops the same span again. The second stopSpan() pops whatever is now on top of the stack instead - typically the caller's entry/local span - corrupting the trace for the rest of the request. beforeMethod() also dereferenced the per-Connection dynamic field without a null check. When it is null (observed for some pooled or recycled connections not captured by the constructor interceptor), this throws before createExitSpan() runs, so afterMethod()'s stopSpan() again pops a span that was never pushed by this interceptor. Fix: only log the error in handleMethodException() (matching jedis-2.x-3.x-plugin's safe behavior) and fall back to an "unknown" peer when the dynamic field is null so the exit span is always pushed and the stack stays balanced. Resolves apache/skywalking#14085
wu-sheng
approved these changes
Sep 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.
What changed
AbstractConnectionInterceptor.handleMethodException()calledContextManager.stopSpan(span)explicitly, but
afterMethod()always runs afterwards too (InstMethodsInterinvokes it in afinallyblock on every path, including exceptions) and stops the same span again. The secondstopSpan()pops whatever is now on top of the stack instead — typically the caller'sentry/local span — corrupting the trace for the rest of the request.
beforeMethod()also dereferenced the per-Connectiondynamic field without a null check. Whenit is null (observed for some pooled/recycled connections not captured by the constructor
interceptor), this throws before
createExitSpan()runs, soafterMethod()'sstopSpan()againpops a span that was never pushed by this interceptor.
Fix
handleMethodException()(matchingjedis-2.x-3.x-plugin's safebehavior) instead of stopping the span a second time.
"unknown"peer when the dynamic field is null so the exit span is alwayspushed and the stack stays balanced.
Testing
./mvnw checkstyle:check -pl apm-sniffer/apm-sdk-plugin/jedis-plugins/jedis-4.x-plugin -am./mvnw test -pl apm-sniffer/apm-sdk-plugin/jedis-plugins/jedis-4.x-plugin -am— BUILD SUCCESSResolves apache/skywalking#14085