Skip to content

Add null checks for calls to getAllLoadedClasses - #12236

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
jpbempel/fix-getLoadedClasses
Aug 19, 2026
Merged

Add null checks for calls to getAllLoadedClasses#12236
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
jpbempel/fix-getLoadedClasses

Conversation

@jpbempel

Copy link
Copy Markdown
Member

What Does This Do

Instrumentation::getAllLoadedClasses can return null slot in the class array in case of class unloading. Make sure that all calls to the method check for null class while iterating over the returned array.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [DEBUG-5575, DEBUG-5922]

Instrumentation::getAllLoadedClasses can return null slot in the
class array in case of class unloading. Make sure that all calls to
the method check for null class while iterating over the returned
array.
@jpbempel
jpbempel requested a review from a team as a code owner August 19, 2026 10:03
@jpbempel
jpbempel requested review from tylfin and removed request for a team August 19, 2026 10:03
@dd-octo-sts

dd-octo-sts Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 929dbd724a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

final Instrumentation instrumentation, final Set<Class<?>> visited) {
List<Class<?>> retransforming = new ArrayList<>();
for (Class<?> clazz : instrumentation.getAllLoadedClasses()) {
if (clazz != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Skip null entries instead of valid loaded classes

When getAllLoadedClasses() returns its normal non-null class entries, this condition skips every one, so the rediscovery strategy returns an empty list and AgentInstaller never retransforms already-loaded classes. If the array does contain the null slot this change intends to handle, that slot instead falls through and is dereferenced on the next line, causing a NullPointerException; reverse the condition so only null entries are skipped.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 19, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 57.99% (-0.45%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9fdc046 | Docs | View more details | Give us feedback!

@jpbempel jpbempel added comp: debugger Dynamic Instrumentation type: bug fix Bug fix labels Aug 19, 2026

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Datadog Autotest: FAIL

The new rediscovery guard skips every non-null loaded class, so retransformation stops immediately; if a null slot appears, that entry is still dereferenced.

Open Bits AI session

🤖 Datadog Autotest · Commit 929dbd7 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

final Instrumentation instrumentation, final Set<Class<?>> visited) {
List<Class<?>> retransforming = new ArrayList<>();
for (Class<?> clazz : instrumentation.getAllLoadedClasses()) {
if (clazz != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Skip null classes instead of loaded classes

Class rediscovery selects no ordinary loaded classes, disabling required retransformation, while the intended null-slot case can still crash the path.

Assertion details
  • Input: Any getAllLoadedClasses() result containing normal non-null classes; a null slot additionally triggers the dereference failure.
  • Expected: Skip null array entries while continuing to evaluate non-null loaded classes for retransformation.
  • Actual: Every non-null class is skipped. A null class proceeds to clazz.getClassLoader() and throws a NullPointerException.
Suggested change
if (clazz != null) {
if (clazz == null) {

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@dd-octo-sts

dd-octo-sts Bot commented Aug 19, 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 14.78 s 14.60 s [+0.4%; +2.2%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.62 s 13.67 s [-1.2%; +0.5%] (no difference)
startup:petclinic:appsec:Agent 16.92 s 16.77 s [-0.1%; +1.8%] (no difference)
startup:petclinic:iast:Agent 16.89 s 16.95 s [-1.3%; +0.4%] (no difference)
startup:petclinic:profiling:Agent 16.59 s 16.84 s [-2.6%; -0.4%] (maybe better)
startup:petclinic:sca:Agent 16.58 s 16.62 s [-1.2%; +0.7%] (no difference)
startup:petclinic:tracing:Agent 16.06 s 16.09 s [-1.1%; +0.7%] (no difference)

Commit: 9fdc0467 · 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.

@pr-commenter

pr-commenter Bot commented Aug 19, 2026

Copy link
Copy Markdown

Debugger benchmarks

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
ci_job_date 1787139317 1787139663
end_time 2026-08-19T11:36:43 2026-08-19T11:42:28
git_branch master jpbempel/fix-getLoadedClasses
git_commit_sha db27f74 9fdc046
start_time 2026-08-19T11:35:18 2026-08-19T11:41:04
See matching parameters
Baseline Candidate
ci_job_id 1964505639 1964505639
ci_pipeline_id 131838028 131838028
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1787138833 1787138833

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 5 unstable metrics.

See unchanged results
scenario Δ mean agg_http_req_duration_min Δ mean agg_http_req_duration_p50 Δ mean agg_http_req_duration_p75 Δ mean agg_http_req_duration_p99 Δ mean throughput
scenario:noprobe unstable
[-14.477µs; +23.488µs] or [-4.980%; +8.080%]
unstable
[-23.954µs; +34.001µs] or [-7.225%; +10.255%]
unstable
[-34.048µs; +46.938µs] or [-9.824%; +13.543%]
unstable
[-232.182µs; +7.199µs] or [-17.714%; +0.549%]
same
scenario:basic same same same unstable
[-288.854µs; +9.852µs] or [-23.708%; +0.809%]
same
scenario:loop same same same same same
Request duration reports for reports
gantt
    title reports - request duration [CI 0.99] : candidate=None, baseline=None
    dateFormat X
    axisFormat %s
section baseline
noprobe (331.545 µs) : 310, 353
.   : milestone, 332,
basic (306.23 µs) : 299, 313
.   : milestone, 306,
loop (8.982 ms) : 8978, 8986
.   : milestone, 8982,
section candidate
noprobe (336.569 µs) : 304, 369
.   : milestone, 337,
basic (307.27 µs) : 300, 314
.   : milestone, 307,
loop (8.981 ms) : 8976, 8986
.   : milestone, 8981,
Loading
  • baseline results
Scenario Request median duration [CI 0.99]
noprobe 331.545 µs [309.619 µs, 353.471 µs]
basic 306.23 µs [299.156 µs, 313.304 µs]
loop 8.982 ms [8.978 ms, 8.986 ms]
  • candidate results
Scenario Request median duration [CI 0.99]
noprobe 336.569 µs [304.36 µs, 368.778 µs]
basic 307.27 µs [300.294 µs, 314.246 µs]
loop 8.981 ms [8.976 ms, 8.986 ms]

@jpbempel
jpbempel added this pull request to the merge queue Aug 19, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 19, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-19 12:16:35 UTC ℹ️ Start processing command /merge


2026-08-19 12:16:39 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-08-19 13:15:04 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 19, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 6007ccb into master Aug 19, 2026
609 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the jpbempel/fix-getLoadedClasses branch August 19, 2026 13:15
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: debugger Dynamic Instrumentation type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants