Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 511e6c0

Browse files
committed
Polish 670b640
* Update year in license headers * Update Javadoc * Remove unused field JOB_PARAMETER_MAXIMUM * Make SecureRandom an instance variable
1 parent 670b640 commit 511e6c0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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
60-
* with the current system time as a parameter. This will ensure restartability
61-
* when no parameters are provided.
60+
* with a random number of type {@code long} as a parameter. This will ensure
61+
* restartability when no parameters are provided.
6262
* </p>
6363
*
6464
* @author Lucas Ward
@@ -69,7 +69,7 @@
6969
*/
7070
public class JobLauncherTestUtils {
7171

72-
private static final long JOB_PARAMETER_MAXIMUM = 1000000;
72+
private SecureRandom secureRandom = new SecureRandom();
7373

7474
/** Logger */
7575
protected final Log logger = LogFactory.getLog(getClass());
@@ -156,12 +156,12 @@ public JobExecution launchJob(JobParameters jobParameters) throws Exception {
156156
}
157157

158158
/**
159-
* @return a new JobParameters object containing only a parameter for the
160-
* current timestamp, to ensure that the job instance will be unique.
159+
* @return a new JobParameters object containing only a parameter with a
160+
* random number of type {@code long}, to ensure that the job instance will be unique.
161161
*/
162162
public JobParameters getUniqueJobParameters() {
163163
Map<String, JobParameter> parameters = new HashMap<>();
164-
parameters.put("random", new JobParameter(new SecureRandom().nextLong()));
164+
parameters.put("random", new JobParameter(this.secureRandom.nextLong()));
165165
return new JobParameters(parameters);
166166
}
167167

spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)