Skip to content

Commit ac0010d

Browse files
PENEKhunfmbenhassine
authored andcommitted
Rename random parameter to batch.random in test utilities
Change the parameter name from 'random' to 'batch.random' in getUniqueJobParameters to prevent collision with user-defined parameters. Framework-provided parameters should use the 'batch.' prefix, similar to execution context attributes. Signed-off-by: PENEKhun <penekhun@gmail.com>
1 parent 2d5c703 commit ac0010d

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
* <p>
5858
* It should be noted that using any of the methods that don't contain
5959
* {@link JobParameters} in their signature, will result in one being created with a
60-
* random number of type {@code long} as a parameter. This will ensure restartability when
61-
* no parameters are provided.
60+
* random number of type {@code long} as a parameter with the name {@code batch.random}.
61+
* This will ensure restartability when no parameters are provided.
6262
* </p>
6363
*
6464
* @author Lucas Ward
@@ -159,16 +159,18 @@ public JobExecution launchJob(JobParameters jobParameters) throws Exception {
159159
}
160160

161161
/**
162-
* @return a new JobParameters object containing only a parameter with a random number
163-
* of type {@code long}, to ensure that the job instance will be unique.
162+
* @return a new {@link JobParameters} object containing only one parameter named
163+
* {@code batch.random} with a random number of type {@code long}, to ensure that the
164+
* job instance will be unique.
164165
*/
165166
public JobParameters getUniqueJobParameters() {
166-
return new JobParameters(Set.of(new JobParameter<>("random", this.secureRandom.nextLong(), Long.class)));
167+
return new JobParameters(Set.of(new JobParameter<>("batch.random", this.secureRandom.nextLong(), Long.class)));
167168
}
168169

169170
/**
170-
* @return a new JobParametersBuilder object containing only a parameter with a random
171-
* number of type {@code long}, to ensure that the job instance will be unique.
171+
* @return a new {@link JobParameters} object containing only one parameter named
172+
* {@code batch.random} with a random number of type {@code long}, to ensure that the
173+
* job instance will be unique.
172174
*/
173175
public JobParametersBuilder getUniqueJobParametersBuilder() {
174176
return new JobParametersBuilder(this.getUniqueJobParameters());

spring-batch-test/src/main/java/org/springframework/batch/test/JobOperatorTestUtils.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
* <p>
6262
* It should be noted that using any of the methods that don't contain
6363
* {@link JobParameters} in their signature, will result in one being created with a
64-
* random number of type {@code long} as a parameter. This will ensure restartability when
65-
* no parameters are provided.
64+
* random number of type {@code long} as a parameter with the name {@code batch.random}.
65+
* This will ensure restartability when no parameters are provided.
6666
* </p>
6767
*
6868
* @author Mahmoud Ben Hassine
@@ -230,17 +230,18 @@ public void beforeJob(JobExecution jobExecution) {
230230
}
231231

232232
/**
233-
* @return a new {@link JobParameters} object containing only a parameter with a
234-
* random number of type {@code long}, to ensure that the job instance will be unique.
233+
* @return a new {@link JobParameters} object containing only one parameter named
234+
* {@code batch.random} with a random number of type {@code long}, to ensure that the
235+
* job instance will be unique.
235236
*/
236237
public JobParameters getUniqueJobParameters() {
237238
return super.getUniqueJobParameters();
238239
}
239240

240241
/**
241-
* @return a new {@link JobParametersBuilder} object containing only a parameter with
242-
* a random number of type {@code long}, to ensure that the job instance will be
243-
* unique.
242+
* @return a new {@link JobParametersBuilder} object containing only one parameter
243+
* named {@code batch.random} with a random number of type {@code long}, to ensure
244+
* that the job instance will be unique.
244245
*/
245246
public JobParametersBuilder getUniqueJobParametersBuilder() {
246247
return super.getUniqueJobParametersBuilder();

0 commit comments

Comments
 (0)