Skip to content

Make decorator exception safe 2/3#12016

Open
PerfectSlayer wants to merge 12 commits into
bbujon/contextfrom
bbujon/safe-decorators
Open

Make decorator exception safe 2/3#12016
PerfectSlayer wants to merge 12 commits into
bbujon/contextfrom
bbujon/safe-decorators

Conversation

@PerfectSlayer

@PerfectSlayer PerfectSlayer commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

This PR is a follow up of #11998 that applies to more signals:

  • BaseDecorator
    • afterStart()
    • onPeerConnection() - no delegation, only locked as no override
  • HttpClientDecorator
    • onRequest()
    • onResponse()
  • HttpServerDecorator
    • onRequest()
    • onResponseStatus()
    • onResponse()

Additionally, document null type and safety for the base decorators.

Motivation

The goal is to simplify how write instrumentations, and make the dumb way safe.

Additional Notes

This part is part of stack PRs:

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@PerfectSlayer
PerfectSlayer requested review from a team as code owners July 21, 2026 09:03
@PerfectSlayer
PerfectSlayer requested review from jordan-wong and ygree and removed request for a team July 21, 2026 09:03

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: FAIL

Found and fixed a critical double-exception-wrapping bug: HttpServerDecorator.doOnResponse() was calling the public wrapper method onResponseStatus() instead of the protected implementation doOnResponseStatus(), causing exceptions to be silently swallowed instead of propagating through the proper exception barrier. This violates the exception-safe decorator pattern established by PR #12016.

View proposed fix
📊 Validated against 3 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 3e2c276 · What is Autotest? · Any feedback? Reach out in #autotest

@datadog-official

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.96 s 13.87 s [+0.0%; +1.2%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.95 s 13.00 s [-1.4%; +0.7%] (no difference)
startup:petclinic:appsec:Agent 17.02 s 16.53 s [+2.1%; +3.9%] (significantly worse)
startup:petclinic:iast:Agent 16.94 s 16.94 s [-0.7%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.67 s 16.85 s [-2.2%; +0.1%] (no difference)
startup:petclinic:sca:Agent 16.93 s 16.89 s [-0.6%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.20 s 16.13 s [-0.6%; +1.5%] (no difference)

Commit: 6cf46e45 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@PerfectSlayer PerfectSlayer changed the title Bbujon/safe decorators Make decorator exception safe 2/3 Jul 21, 2026
import io.grpc.StatusRuntimeException;
import java.util.BitSet;
import java.util.function.Function;
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong import?

@PerfectSlayer PerfectSlayer Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I have a hard time with IDEA importing various null check libraries... I have seen the one from javax, findbugs, JSpecify, Jetbrains, in addition to this one... I changed for javax like the other ones.

It happens when I asked it to add the annotations for various overrides. I guess it picks the one that are already in the classpath. And as various instrumentations have various classpath, they might have their own null check libraries which take priority.

I had a look at the codebase and I found some in context work too 😅

@mcculls mcculls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various comments (mostly around the wide variety of different @NonNulls being imported) but nothing blocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants