Skip to content

Avoid final field modifications in Cucumber and Spock instrumentations#11851

Open
daniel-mohedano wants to merge 1 commit into
daniel.mohedano/fix-cucumber-retriesfrom
daniel.mohedano/jep-500-cucumber-spock
Open

Avoid final field modifications in Cucumber and Spock instrumentations#11851
daniel-mohedano wants to merge 1 commit into
daniel.mohedano/fix-cucumber-retriesfrom
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: enhancement 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

Copy link
Copy Markdown

Test Environment - sbt-scalatest

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 56.10 55.43 $\color{red}{\blacktriangle}$ +0.67 55.43 $\color{red}{\blacktriangle}$ +0.67 56/198
agentEvpProxy 55.81 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

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 35.79 36.42 $\color{green}{\blacktriangledown}$ -0.63 36.42 $\color{green}{\blacktriangledown}$ -0.63 30/98
agentless 34.94 35.70 $\color{green}{\blacktriangledown}$ -0.76 35.70 $\color{green}{\blacktriangledown}$ -0.76 30/98
agentlessCodeCoverage 43.65 43.60 $\color{red}{\blacktriangle}$ +0.05 43.60 $\color{red}{\blacktriangle}$ +0.05 30/98
agentlessLineCoverage 74.03 74.82 $\color{green}{\blacktriangledown}$ -0.79 74.82 $\color{green}{\blacktriangledown}$ -0.79 29/97

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 - netflix-zuul

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 86.56 86.07 $\color{red}{\blacktriangle}$ +0.49 86.07 $\color{red}{\blacktriangle}$ +0.49 31/145
agentless 80.82 81.05 $\color{green}{\blacktriangledown}$ -0.23 81.05 $\color{green}{\blacktriangledown}$ -0.23 32/145
agentlessCodeCoverage 95.64 95.12 $\color{red}{\blacktriangle}$ +0.52 95.12 $\color{red}{\blacktriangle}$ +0.52 31/142
agentlessLineCoverage 112.50 111.62 $\color{red}{\blacktriangle}$ +0.88 111.62 $\color{red}{\blacktriangle}$ +0.88 30/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

Copy link
Copy Markdown

Test Environment - pass4s

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 7.12 10.75 $\color{green}{\blacktriangledown}$ -3.63 10.33 $\color{green}{\blacktriangledown}$ -3.21 27/98
agentless 7.58 10.75 $\color{green}{\blacktriangledown}$ -3.17 9.92 $\color{green}{\blacktriangledown}$ -2.34 27/99
agentlessCodeCoverage 21.48 18.08 $\color{red}{\blacktriangle}$ +3.40 17.73 $\color{red}{\blacktriangle}$ +3.75 26/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.

@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

Copy link
Copy Markdown

Test Environment - sonar-kotlin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 12.29 13.13 $\color{green}{\blacktriangledown}$ -0.84 13.13 $\color{green}{\blacktriangledown}$ -0.84 30/100
agentless 12.63 12.12 $\color{red}{\blacktriangle}$ +0.51 11.88 $\color{red}{\blacktriangle}$ +0.75 29/99
agentlessCodeCoverage 15.62 15.41 $\color{red}{\blacktriangle}$ +0.21 15.11 $\color{red}{\blacktriangle}$ +0.51 29/99
agentlessLineCoverage 18.26 19.20 $\color{green}{\blacktriangledown}$ -0.94 19.20 $\color{green}{\blacktriangledown}$ -0.94 29/99

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 - jolokia

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 90.93 93.23 $\color{green}{\blacktriangledown}$ -2.30 93.23 $\color{green}{\blacktriangledown}$ -2.30 29/101
agentless 88.43 87.80 $\color{red}{\blacktriangle}$ +0.63 89.58 $\color{green}{\blacktriangledown}$ -1.15 29/101
agentlessCodeCoverage 97.62 99.00 $\color{green}{\blacktriangledown}$ -1.38 99.00 $\color{green}{\blacktriangledown}$ -1.38 28/98
agentlessLineCoverage 97.61 99.00 $\color{green}{\blacktriangledown}$ -1.39 99.00 $\color{green}{\blacktriangledown}$ -1.39 27/97

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

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.10 16.04 $\color{red}{\blacktriangle}$ +0.06 16.04 $\color{red}{\blacktriangle}$ +0.06 26/95
agentless 9.56 9.73 $\color{green}{\blacktriangledown}$ -0.17 9.73 $\color{green}{\blacktriangledown}$ -0.17 26/95
agentlessCodeCoverage 14.15 13.13 $\color{red}{\blacktriangle}$ +1.02 13.40 $\color{red}{\blacktriangle}$ +0.75 26/94
agentlessLineCoverage 32.72 32.95 $\color{green}{\blacktriangledown}$ -0.23 32.30 $\color{red}{\blacktriangle}$ +0.42 25/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

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

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