Commit e56b048
amos.chen
Fix jedis-4.x-plugin double-stopping the span stack on Redis exceptions
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#140851 parent e9b8826 commit e56b048
2 files changed
Lines changed: 19 additions & 4 deletions
File tree
- apm-sniffer/apm-sdk-plugin/jedis-plugins/jedis-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v4
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
57 | | - | |
| 65 | + | |
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | | - | |
| 71 | + | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
| |||
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
87 | | - | |
88 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
| |||
0 commit comments