-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Milestone
Description
Expected Behavior
The key used for the job parameter generated by getUniqueJobParameters() should never conflict with parameter names defined in a user’s job. Users should be able to call getUniqueJobParametersBuilder() and add any parameter name freely, without the risk of overwriting the framework-generated unique parameter.
Current Behavior
Currently, getUniqueJobParameters() uses a hardcoded "random" key.
public JobParameters getUniqueJobParameters() {
return new JobParameters(Set.of(
new JobParameter<>("random", this.secureRandom.nextLong(), Long.class)
));
}This creates a collision risk because
JobParameters params = jobOperatorTestUtils.getUniqueJobParametersBuilder()
.addLong("random", 12345L) // Overwrites the unique parameter!
.toJobParameters();The current behavior makes it impossible to safely use getUniqueJobParametersBuilder() when a user’s job already defines a parameter named "random". In this case, the user-provided "random" parameter overwrites the framework-generated one, creating an unintended collision.
Context
- Q: What other alternatives have you considered?
-
- Use a namespaced key (e.g.,
spring.batch.test.unique) insteadrandomkey.
- Use a namespaced key (e.g.,
-
- UUID as key + descriptive value (e.g.,
{UUID="Auto-generated by Spring Batch Test for unique job parameters"})
- UUID as key + descriptive value (e.g.,
-