Skip to content

Avoid final field modification in JUnit5 instrumentation#11752

Open
daniel-mohedano wants to merge 2 commits into
masterfrom
daniel.mohedano/jep-500-junit
Open

Avoid final field modification in JUnit5 instrumentation#11752
daniel-mohedano wants to merge 2 commits into
masterfrom
daniel.mohedano/jep-500-junit

Conversation

@daniel-mohedano

@daniel-mohedano daniel-mohedano commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

  • Avoids final field modifications in JUnit5 instrumentation by:
    • Building a fresh TestTask for every retry, reusing the original parent context, instead of reusing and modifying the original test task. This approach is only supported for versions 5.3.1+.
    • Introducing a new TestDescriptor cloning method based on JupiterTestDescriptor#copyIncludingDescendants(UnaryOperator<UniqueId>)}, which also avoids manually setting the generated uniqueId after the cloning. This approach is only supported for versions 5.13+.

Motivation

Avoid failures in future JDKs due to JEP 500: Prepare to Make Final Mean Final.

Additional Notes

Running an example project on JDK26 with JAVA_TOOL_OPTIONS=--illegal-final-field-mutation=debug produced the following logs:

Final field testDescriptor in class org.junit.platform.engine.support.hierarchical.NodeTestTask has been unreflected for mutation ...
Final field node in class org.junit.platform.engine.support.hierarchical.NodeTestTask has been unreflected for mutation ...
Final field uniqueId in class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor has been unreflected for mutation ...
Final field interceptorCall in class org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor has been mutated reflectively ...
Final field methodInfo in class org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor has been mutated reflectively ...
Final field configuration in class org.junit.jupiter.engine.descriptor.JupiterTestDescriptor has been mutated reflectively ...
...

The build containing the fix doesn't produce the logs.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: SDTEST-3867

@daniel-mohedano daniel-mohedano added type: enhancement Enhancements and improvements comp: ci visibility Continuous Integration Visibility labels Jun 26, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - sbt-scalatest

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 55.94 55.43 $\color{red}{\blacktriangle}$ +0.51 55.43 $\color{red}{\blacktriangle}$ +0.51 58/192
agentEvpProxy 55.04 n/a n/a n/a n/a -

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - nebula-release-plugin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 37.76 36.42 $\color{red}{\blacktriangle}$ +1.34 36.42 $\color{red}{\blacktriangle}$ +1.34 31/96
agentless 36.31 35.70 $\color{red}{\blacktriangle}$ +0.61 35.70 $\color{red}{\blacktriangle}$ +0.61 30/95
agentlessCodeCoverage 44.48 43.60 $\color{red}{\blacktriangle}$ +0.88 43.60 $\color{red}{\blacktriangle}$ +0.88 30/95
agentlessLineCoverage 73.29 74.82 $\color{green}{\blacktriangledown}$ -1.53 74.82 $\color{green}{\blacktriangledown}$ -1.53 29/94

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - netflix-zuul

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 87.17 86.07 $\color{red}{\blacktriangle}$ +1.10 86.07 $\color{red}{\blacktriangle}$ +1.10 29/140
agentless 80.18 81.05 $\color{green}{\blacktriangledown}$ -0.87 81.05 $\color{green}{\blacktriangledown}$ -0.87 30/140
agentlessCodeCoverage 95.12 95.12 $\color{gray}{\bullet}$ 0.00 95.12 $\color{gray}{\bullet}$ 0.00 29/137
agentlessLineCoverage 111.17 111.62 $\color{green}{\blacktriangledown}$ -0.45 111.62 $\color{green}{\blacktriangledown}$ -0.45 29/137

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - pass4s

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 15.78 10.97 $\color{red}{\blacktriangle}$ +4.81 10.13 $\color{red}{\blacktriangle}$ +5.65 29/94
agentless 9.02 10.75 $\color{green}{\blacktriangledown}$ -1.73 9.73 $\color{green}{\blacktriangledown}$ -0.71 29/95
agentlessCodeCoverage 15.09 18.08 $\color{green}{\blacktriangledown}$ -2.99 17.73 $\color{green}{\blacktriangledown}$ -2.64 27/92

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - reactive-streams-jvm

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 21.68 21.65 $\color{red}{\blacktriangle}$ +0.03 21.65 $\color{red}{\blacktriangle}$ +0.03 31/145
agentless 18.60 18.45 $\color{red}{\blacktriangle}$ +0.15 18.82 $\color{green}{\blacktriangledown}$ -0.22 30/143
agentlessCodeCoverage 20.70 19.99 $\color{red}{\blacktriangle}$ +0.71 19.99 $\color{red}{\blacktriangle}$ +0.71 29/142
agentlessLineCoverage 30.40 29.82 $\color{red}{\blacktriangle}$ +0.58 29.82 $\color{red}{\blacktriangle}$ +0.58 28/141

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - jolokia

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 93.36 93.23 $\color{red}{\blacktriangle}$ +0.13 93.23 $\color{red}{\blacktriangle}$ +0.13 32/100
agentless 89.01 89.58 $\color{green}{\blacktriangledown}$ -0.57 89.58 $\color{green}{\blacktriangledown}$ -0.57 32/100
agentlessCodeCoverage 98.00 99.00 $\color{green}{\blacktriangledown}$ -1.00 99.00 $\color{green}{\blacktriangledown}$ -1.00 30/97
agentlessLineCoverage 97.73 99.00 $\color{green}{\blacktriangledown}$ -1.27 99.00 $\color{green}{\blacktriangledown}$ -1.27 28/95

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - okhttp

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 19.68 19.20 $\color{red}{\blacktriangle}$ +0.48 19.59 $\color{red}{\blacktriangle}$ +0.09 33/102
agentless 17.91 18.82 $\color{green}{\blacktriangledown}$ -0.91 19.20 $\color{green}{\blacktriangledown}$ -1.29 33/102
agentlessCodeCoverage 22.88 22.09 $\color{red}{\blacktriangle}$ +0.79 22.09 $\color{red}{\blacktriangle}$ +0.79 32/99
agentlessLineCoverage 45.36 44.48 $\color{red}{\blacktriangle}$ +0.88 44.48 $\color{red}{\blacktriangle}$ +0.88 34/103

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 26, 2026

Copy link
Copy Markdown

Test Environment - sonar-java

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 8.30 12.87 $\color{green}{\blacktriangledown}$ -4.57 15.72 $\color{green}{\blacktriangledown}$ -7.42 31/99
agentless 26.16 19.99 $\color{red}{\blacktriangle}$ +6.17 16.04 $\color{red}{\blacktriangle}$ +10.12 30/98
agentlessCodeCoverage 73.47 86.07 $\color{green}{\blacktriangledown}$ -12.60 87.80 $\color{green}{\blacktriangledown}$ -14.33 30/98
agentlessLineCoverage 139.70 133.64 $\color{red}{\blacktriangle}$ +6.06 141.90 $\color{green}{\blacktriangledown}$ -2.20 28/96

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@daniel-mohedano daniel-mohedano marked this pull request as ready for review June 29, 2026 14:58
@daniel-mohedano daniel-mohedano requested a review from a team as a code owner June 29, 2026 14:58

@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: PASS

More details

Three critical correctness invariants hold: (1) ThrowableCollectorFactoryWrapper is installed on NodeTestTaskContext (shared across all retry tasks), so factory.setSuppressFailures() correctly controls each retry even though currentTask is now a fresh NodeTestTask; (2) AbstractTestDescriptor.setParent() only sets the child's parent reference without addChild(), so the snapshot and retry descriptors are not injected into the parent's children list; (3) legacyCopy's new conditional uniqueId setter is correct — tryShallowClone already copies all fields including uniqueId, so the setter is only needed when the ID actually changes.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@datadog-official

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 69.73% (+14.70%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b5ae13c | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - sonar-kotlin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 13.95 13.40 $\color{red}{\blacktriangle}$ +0.55 13.13 $\color{red}{\blacktriangle}$ +0.82 30/96
agentless 12.12 12.12 $\color{gray}{\bullet}$ 0.00 11.88 $\color{red}{\blacktriangle}$ +0.24 28/94
agentlessCodeCoverage 17.10 15.41 $\color{red}{\blacktriangle}$ +1.69 15.11 $\color{red}{\blacktriangle}$ +1.99 28/94
agentlessLineCoverage 20.52 19.20 $\color{red}{\blacktriangle}$ +1.32 19.20 $\color{red}{\blacktriangle}$ +1.32 28/94

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 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.98 s 13.91 s [-0.2%; +1.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.84 s 12.95 s [-1.5%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 16.87 s 16.79 s [-0.7%; +1.7%] (no difference)
startup:petclinic:iast:Agent 16.44 s 16.89 s [-7.0%; +1.6%] (no difference)
startup:petclinic:profiling:Agent 16.28 s 16.86 s [-8.0%; +1.1%] (no difference)
startup:petclinic:sca:Agent 16.82 s 16.82 s [-1.1%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.05 s 16.03 s [-0.7%; +1.0%] (no difference)

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

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

Labels

comp: ci visibility Continuous Integration Visibility type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants