Skip to content

Avoid final field modifications in Cucumber and Spock instrumentations#11851

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
daniel.mohedano/jep-500-cucumber-spock
Jul 10, 2026
Merged

Avoid final field modifications in Cucumber and Spock instrumentations#11851
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
daniel.mohedano/jep-500-cucumber-spock

Conversation

@daniel-mohedano

@daniel-mohedano daniel-mohedano commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

  • Introduces a new RetryDescriptorFactory for JUnit5-based framework instrumentations.
    • Spock and Cucumber instrumentations register their own retry descriptor generators (by using available constructors) in order to keep the JUnit5 execution instrumentation framework-agnostic while avoiding JEP 500 warnings.

Motivation

#11752 approach to avoid final field modifications in JUnit5 only applied to JupiterTestDescriptor, which is only used by JUnit5. Both Spock and Cucumber implement their own kind of descriptors, which still depended on the non-JEP500-compliant approach to enable execution policies.

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 pickle in class io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor has been mutated reflectively...
Final field tags in class io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor has been mutated reflectively...
Final field exclusiveResources in class io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor has been mutated reflectively...
Final field executionMode in class io.cucumber.junit.platform.engine.NodeDescriptor has been mutated reflectively...
Final field uniqueId in class org.junit.platform.engine.support.descriptor.AbstractTestDescriptor 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-3892

@daniel-mohedano daniel-mohedano added type: feature Enhancements and improvements comp: ci visibility Continuous Integration Visibility labels Jul 3, 2026
@daniel-mohedano daniel-mohedano changed the base branch from master to daniel.mohedano/fix-cucumber-retries July 3, 2026 09:22
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 3, 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.88 54.33 $\color{red}{\blacktriangle}$ +1.55 54.33 $\color{red}{\blacktriangle}$ +1.55 54/214
agentEvpProxy 55.03 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 Jul 3, 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.98 37.15 $\color{red}{\blacktriangle}$ +0.83 36.42 $\color{red}{\blacktriangle}$ +1.56 27/105
agentless 38.01 36.42 $\color{red}{\blacktriangle}$ +1.59 36.42 $\color{red}{\blacktriangle}$ +1.59 27/105
agentlessCodeCoverage 45.26 44.48 $\color{red}{\blacktriangle}$ +0.78 44.48 $\color{red}{\blacktriangle}$ +0.78 27/105
agentlessLineCoverage 76.18 74.82 $\color{red}{\blacktriangle}$ +1.36 74.82 $\color{red}{\blacktriangle}$ +1.36 26/104

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 Jul 3, 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 86.44 87.80 $\color{green}{\blacktriangledown}$ -1.36 87.80 $\color{green}{\blacktriangledown}$ -1.36 29/117
agentless 80.49 81.05 $\color{green}{\blacktriangledown}$ -0.56 81.05 $\color{green}{\blacktriangledown}$ -0.56 30/118
agentlessCodeCoverage 95.52 97.04 $\color{green}{\blacktriangledown}$ -1.52 95.12 $\color{red}{\blacktriangle}$ +0.40 29/114
agentlessLineCoverage 112.27 111.62 $\color{red}{\blacktriangle}$ +0.65 111.62 $\color{red}{\blacktriangle}$ +0.65 28/113

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 Jul 3, 2026

Copy link
Copy Markdown

Test Environment - pass4s

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 9.08 10.54 $\color{green}{\blacktriangledown}$ -1.46 10.33 $\color{green}{\blacktriangledown}$ -1.25 27/107
agentless 12.43 9.73 $\color{red}{\blacktriangle}$ +2.70 9.73 $\color{red}{\blacktriangle}$ +2.70 27/107
agentlessCodeCoverage 16.18 17.03 $\color{green}{\blacktriangledown}$ -0.85 17.73 $\color{green}{\blacktriangledown}$ -1.55 26/105

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

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 20.40 21.65 $\color{green}{\blacktriangledown}$ -1.25 21.65 $\color{green}{\blacktriangledown}$ -1.25 29/143
agentless 18.44 18.45 $\color{green}{\blacktriangledown}$ -0.01 18.82 $\color{green}{\blacktriangledown}$ -0.38 30/142
agentlessCodeCoverage 19.34 19.99 $\color{green}{\blacktriangledown}$ -0.65 19.99 $\color{green}{\blacktriangledown}$ -0.65 29/141
agentlessLineCoverage 29.25 29.82 $\color{green}{\blacktriangledown}$ -0.57 29.82 $\color{green}{\blacktriangledown}$ -0.57 28/140

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 Jul 3, 2026

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.03 12.62 $\color{red}{\blacktriangle}$ +0.41 13.13 $\color{green}{\blacktriangledown}$ -0.10 27/108
agentless 12.80 12.37 $\color{red}{\blacktriangle}$ +0.43 12.12 $\color{red}{\blacktriangle}$ +0.68 27/107
agentlessCodeCoverage 15.76 15.11 $\color{red}{\blacktriangle}$ +0.65 15.11 $\color{red}{\blacktriangle}$ +0.65 27/107
agentlessLineCoverage 19.10 18.82 $\color{red}{\blacktriangle}$ +0.28 18.82 $\color{red}{\blacktriangle}$ +0.28 26/107

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 Jul 3, 2026

Copy link
Copy Markdown

Test Environment - jolokia

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 96.30 93.23 $\color{red}{\blacktriangle}$ +3.07 93.23 $\color{red}{\blacktriangle}$ +3.07 30/113
agentless 89.56 89.58 $\color{green}{\blacktriangledown}$ -0.02 89.58 $\color{green}{\blacktriangledown}$ -0.02 28/110
agentlessCodeCoverage 99.22 99.00 $\color{red}{\blacktriangle}$ +0.22 99.00 $\color{red}{\blacktriangle}$ +0.22 29/109
agentlessLineCoverage 100.24 99.00 $\color{red}{\blacktriangle}$ +1.24 99.00 $\color{red}{\blacktriangle}$ +1.24 28/108

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 July 3, 2026 09:53
@daniel-mohedano daniel-mohedano requested a review from a team as a code owner July 3, 2026 09:53
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - okhttp

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 20.23 19.20 $\color{red}{\blacktriangle}$ +1.03 19.59 $\color{red}{\blacktriangle}$ +0.64 32/106
agentless 18.69 19.20 $\color{green}{\blacktriangledown}$ -0.51 19.20 $\color{green}{\blacktriangledown}$ -0.51 32/106
agentlessCodeCoverage 21.36 22.54 $\color{green}{\blacktriangledown}$ -1.18 22.09 $\color{green}{\blacktriangledown}$ -0.73 31/103
agentlessLineCoverage 44.66 44.48 $\color{red}{\blacktriangle}$ +0.18 44.48 $\color{red}{\blacktriangle}$ +0.18 32/108

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.

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

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +86 to +90
CONSTRUCTOR_7_7, new EmptyConfigurationParameters(), newId, name, source, pickle);
}
if (CONSTRUCTOR_6_0 != null) {
return METHOD_HANDLES.invoke(
CONSTRUCTOR_6_0, new EmptyConfigurationParameters(), newId, name, source, pickle);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve Cucumber parameters for retry descriptors

For Cucumber 6.0–7.23, PickleDescriptor derives its execution mode and tag-based exclusive resources from the ConfigurationParameters passed to this constructor (for example, the 7.23 source computes both from parameters: https://github.com/cucumber/cucumber-jvm/blob/v7.23.0/cucumber-junit-platform-engine/src/main/java/io/cucumber/junit/platform/engine/NodeDescriptor.java). Passing EmptyConfigurationParameters here means retries for suites that configure non-default feature execution mode or cucumber.execution.exclusive-resources.* are rebuilt with default concurrent mode and no resource locks, while the previous shallow clone preserved those fields; those retries can therefore be scheduled differently from the original scenario.

Useful? React with 👍 / 👎.

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.

Seems like the execution mode and exclusive resources are read by the HierarchicalTestExecutorService when planning on how to run a test task. But the retry descriptors are only ever executed by us manually in the execution instrumentation through currentTask.execute() without scheduling, so the fields are never used.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 3, 2026

Copy link
Copy Markdown

Test Environment - spring_boot

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 16.25 16.36 $\color{green}{\blacktriangledown}$ -0.11 16.04 $\color{red}{\blacktriangle}$ +0.21 28/103
agentless 9.67 9.73 $\color{green}{\blacktriangledown}$ -0.06 9.73 $\color{green}{\blacktriangledown}$ -0.06 29/104
agentlessCodeCoverage 13.39 13.40 $\color{green}{\blacktriangledown}$ -0.01 13.40 $\color{green}{\blacktriangledown}$ -0.01 28/102
agentlessLineCoverage 32.43 32.95 $\color{green}{\blacktriangledown}$ -0.52 32.30 $\color{red}{\blacktriangle}$ +0.13 27/102

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

Copy link
Copy Markdown

Test Environment - sonar-java

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 0.56 13.94 $\color{green}{\blacktriangledown}$ -13.38 15.72 $\color{green}{\blacktriangledown}$ -15.16 30/102
agentless 27.27 24.41 $\color{red}{\blacktriangle}$ +2.86 19.59 $\color{red}{\blacktriangle}$ +7.68 30/101
agentlessCodeCoverage 88.10 87.80 $\color{red}{\blacktriangle}$ +0.30 89.58 $\color{green}{\blacktriangledown}$ -1.48 30/101
agentlessLineCoverage 117.02 144.77 $\color{green}{\blacktriangledown}$ -27.75 141.90 $\color{green}{\blacktriangledown}$ -24.88 29/100

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

Copy link
Copy Markdown
Contributor Author

/datadog autotest review

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

PR implements JEP 500-compliant descriptor reconstruction for Spock and Cucumber tests by avoiding final field mutations. Code is safe and correct: all null cases handled via defensive MethodHandles patterns, fallback to legacy cloning preserved, registration timing correct, and no behavioral regressions introduced.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

Base automatically changed from daniel.mohedano/fix-cucumber-retries to master July 10, 2026 10:13
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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

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

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - heliboard

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 9.47 9.54 $\color{green}{\blacktriangledown}$ -0.07 9.54 $\color{green}{\blacktriangledown}$ -0.07 15/15

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 10, 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.89 s 13.99 s [-1.5%; +0.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.85 s 13.07 s [-2.2%; -1.1%] (significantly better)
startup:petclinic:appsec:Agent 17.02 s 16.83 s [-0.0%; +2.3%] (no difference)
startup:petclinic:iast:Agent 16.92 s 17.10 s [-1.9%; -0.1%] (maybe better)
startup:petclinic:profiling:Agent 16.69 s 16.77 s [-1.7%; +0.8%] (no difference)
startup:petclinic:sca:Agent 17.05 s 16.86 s [+0.1%; +2.2%] (maybe worse)
startup:petclinic:tracing:Agent 16.12 s 15.63 s [-1.2%; +7.5%] (no difference)

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

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

The retry-descriptor factory dispatch chain (RetryDescriptorFactoriesCucumberRetryDescriptorFactory / SpockRetryDescriptorFactorylegacyCopy) is correctly wired. The legacyCopy guard condition (descriptorClone != testDescriptor && !updatedId.equals(...)) correctly prevents modifying the live descriptor on Unsafe failure. The CallDepthThreadLocalMap depth check ensures the ExecutionAdvice does not re-enter itself when the fresh retry NodeTestTask calls execute(). Seven targeted unit tests covering the registry, null-engine guard, overwrite semantics, id-suffix walk, and factory null-return fallback all pass.

Was this helpful? React 👍 or 👎

📊 Validated against 7 scenarios · Open Bits AI session

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

@daniel-mohedano

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 10, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-10 11:10:42 UTC ℹ️ Start processing command /merge


2026-07-10 11:10:46 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-10 12:07:30 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 9e673a6 into master Jul 10, 2026
586 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the daniel.mohedano/jep-500-cucumber-spock branch July 10, 2026 12:07
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 10, 2026
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: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants