From ab3d65ccaef6fe747e3f26797d57c920fd6f538b Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Thu, 12 Oct 2017 11:17:46 +0200 Subject: [PATCH] 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 --- .../batch/JobLauncherCommandLineRunner.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java index ec6c78e5511..37a9b4e1eee 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java @@ -181,8 +181,7 @@ public class JobLauncherCommandLineRunner Map merged = new HashMap(); merged.putAll(parameters.getParameters()); merged.putAll(additionals); - parameters = new JobParameters(merged); - return parameters; + return new JobParameters(merged); } private void executeRegisteredJobs(JobParameters jobParameters) @@ -199,7 +198,6 @@ public class JobLauncherCommandLineRunner } catch (NoSuchJobException ex) { logger.debug("No job found in registry for job name: " + jobName); - continue; } } } @@ -210,11 +208,9 @@ public class JobLauncherCommandLineRunner JobInstanceAlreadyCompleteException, JobParametersInvalidException, JobParametersNotFoundException { JobParameters nextParameters = getNextJobParameters(job, jobParameters); - if (nextParameters != null) { - JobExecution execution = this.jobLauncher.run(job, nextParameters); - if (this.publisher != null) { - this.publisher.publishEvent(new JobExecutionEvent(execution)); - } + JobExecution execution = this.jobLauncher.run(job, nextParameters); + if (this.publisher != null) { + this.publisher.publishEvent(new JobExecutionEvent(execution)); } }