Repository navigation
Guard Tomcat CoyoteAdapter advice against null-scope NPE (quick fix) - #12375
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
If extractParent()/onService() throws before assigning its @Advice.Local ContextScope, the throwable is swallowed (suppress = Throwable.class), and the paired closeScope() then NPEs on the still-null local, masking the real failure and producing a misleading "Failed to handle exception in instrumentation for CoyoteAdapter" log entry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
Guards the Tomcat
CoyoteAdapterserver advice against a null-scopeNullPointerExceptionthat can occur if the paired enter-advice fails before assigning its@Advice.LocalContextScope.TomcatServerInstrumentation.ContextTrackingAdvice.closeScopeandTomcatServerInstrumentation.ServiceAdvice.closeScopeboth called.close()unconditionally on an@Advice.LocalContextScope. Both are guarded withif (scope != null)now.Motivation
Error Tracking issue: https://app.datadoghq.com/error-tracking/issue/5ce30218-b43b-11f0-ac08-da7ad0900002
Logged via the agent's own suppressed-exception mechanism as:
ContextTrackingAdvice.extractParentandServiceAdvice.onServiceare both@Advice.OnMethodEnter(suppress = Throwable.class). If either throws before assigning its@Advice.LocalContextScope(e.g.DECORATE.extract(req),DECORATE.startSpan(...), or a request-attribute call throwing inside an app's customRequest/attribute wrapper), the exception is silently swallowed by ByteBuddy's suppression bytecode.CoyoteAdapter.service()then proceeds normally, and the paired@Advice.OnMethodExitcloseScopeunconditionally calls.close()on the still-null local — a second NPE that is also swallowed and logged, fully masking the original failure. Because both exceptions are handled by generated advice bytecode rather than real application frames, the visible stack trace is almost entirely redacted, which is why this surfaces as a bareVirtualThread.runframe with no other context.A related but narrower instance of this same failure mode (
parentContext == nullspecifically) was already fixed in #11968 (rootContext()fallback), but the underlying structural issue —closeScopenot tolerating a null local — was never addressed, so any other exception in the enter-advice reproduces the same NPE.Additional Notes
Added a direct JUnit 5 unit test (
TomcatServerInstrumentationTest) calling the twocloseScopeadvice methods withnulland with a realContextScope, since both are plain public static methods andContextScopeis an interface — no bytecode instrumentation harness or mocking framework needed.Contributor Checklist
docs/release_notes.mdif this change affects the user-facing functionality. — N/A, internal fix.Jira ticket: [PROJ-IDENT]