Skip to content

Parameter resolution in SpringExtension is not thread-safe [SPR-17533] #22065

@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-17533 and commented

Status Quo

ParameterAutowireUtils (used internally by the SpringExtension) creates a SynthesizingMethodParameter via SynthesizingMethodParameter.forParameter() which looks up the index of the current Parameter via MethodParameter.findParameterIndex(Parameter).

findParameterIndex() iterates over the array of parameters returned from java.lang.reflect.Executable.getParameters() which is unfortunately not thread-safe.

Specifically, the implementation of java.lang.reflect.Executable.privateGetParameters() writes to a private transient volatile Parameter[] parameters field in such a way that competing threads may receive references to different arrays.

Deliverables

  1. Ensure that parameter resolution within the SpringExtension is thread-safe.

Affects: 5.0.10, 5.1 GA

Reference URL: junit-team/junit-framework#1686

Issue Links:

Referenced from: commits 58cde3c, aa7f69a, cd67b28

Backported to: 5.0.11

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions