Skip to content

Commit ab3d65c

Browse files
mdeinumsnicoll
authored andcommitted
Polish JobLauncherCommandLineRunner
The JobLauncherCommandLineRunner reassigned method arguments inside the merge method. Instead of reassigning the method argument just return the new instance directly. Also some minor cleanup (unnesseccary null check and continue keyword). Closes gh-10612
1 parent 51551fe commit ab3d65c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ private JobParameters merge(JobParameters parameters,
181181
Map<String, JobParameter> merged = new HashMap<String, JobParameter>();
182182
merged.putAll(parameters.getParameters());
183183
merged.putAll(additionals);
184-
parameters = new JobParameters(merged);
185-
return parameters;
184+
return new JobParameters(merged);
186185
}
187186

188187
private void executeRegisteredJobs(JobParameters jobParameters)
@@ -199,7 +198,6 @@ private void executeRegisteredJobs(JobParameters jobParameters)
199198
}
200199
catch (NoSuchJobException ex) {
201200
logger.debug("No job found in registry for job name: " + jobName);
202-
continue;
203201
}
204202
}
205203
}
@@ -210,11 +208,9 @@ protected void execute(Job job, JobParameters jobParameters)
210208
JobInstanceAlreadyCompleteException, JobParametersInvalidException,
211209
JobParametersNotFoundException {
212210
JobParameters nextParameters = getNextJobParameters(job, jobParameters);
213-
if (nextParameters != null) {
214-
JobExecution execution = this.jobLauncher.run(job, nextParameters);
215-
if (this.publisher != null) {
216-
this.publisher.publishEvent(new JobExecutionEvent(execution));
217-
}
211+
JobExecution execution = this.jobLauncher.run(job, nextParameters);
212+
if (this.publisher != null) {
213+
this.publisher.publishEvent(new JobExecutionEvent(execution));
218214
}
219215
}
220216

0 commit comments

Comments
 (0)