Skip to content

Commit c1cd43d

Browse files
committed
Merge pull request #47477 from fmbenhassine
* pr/47477: Polish "Start building against Spring Batch 6.0.0-RC1 snapshots" Start building against Spring Batch 6.0.0-RC1 snapshots See gh-47484 Closes gh-47477
2 parents d25073f + 8cd7c22 commit c1cd43d

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
import org.springframework.batch.core.job.Job;
3232
import org.springframework.batch.core.job.JobExecution;
3333
import org.springframework.batch.core.job.JobExecutionException;
34+
import org.springframework.batch.core.job.parameters.InvalidJobParametersException;
3435
import org.springframework.batch.core.job.parameters.JobParameters;
35-
import org.springframework.batch.core.job.parameters.JobParametersInvalidException;
36+
import org.springframework.batch.core.launch.JobExecutionAlreadyRunningException;
37+
import org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException;
3638
import org.springframework.batch.core.launch.JobOperator;
37-
import org.springframework.batch.core.launch.NoSuchJobException;
38-
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
39-
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
40-
import org.springframework.batch.core.repository.JobRestartException;
39+
import org.springframework.batch.core.launch.JobRestartException;
4140
import org.springframework.beans.factory.InitializingBean;
4241
import org.springframework.beans.factory.annotation.Autowired;
4342
import org.springframework.boot.ApplicationArguments;
@@ -146,10 +145,11 @@ public void run(ApplicationArguments args) throws Exception {
146145

147146
public void run(String... args) throws JobExecutionException {
148147
logger.info("Running default command line with: " + Arrays.asList(args));
149-
launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="));
148+
Properties properties = StringUtils.splitArrayElementsIntoProperties(args, "=");
149+
launchJobFromProperties((properties != null) ? properties : new Properties());
150150
}
151151

152-
protected void launchJobFromProperties(@Nullable Properties properties) throws JobExecutionException {
152+
protected void launchJobFromProperties(Properties properties) throws JobExecutionException {
153153
JobParameters jobParameters = this.converter.getJobParameters(properties);
154154
executeLocalJobs(jobParameters);
155155
executeRegisteredJobs(jobParameters);
@@ -179,14 +179,14 @@ private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecut
179179
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) {
180180
if (!isLocalJob(this.jobName)) {
181181
Job job = this.jobRegistry.getJob(this.jobName);
182+
Assert.notNull(job, () -> "No job found with name '" + this.jobName + "'");
182183
execute(job, jobParameters);
183184
}
184185
}
185186
}
186187

187-
protected void execute(Job job, JobParameters jobParameters)
188-
throws JobExecutionAlreadyRunningException, NoSuchJobException, JobRestartException,
189-
JobInstanceAlreadyCompleteException, JobParametersInvalidException {
188+
protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
189+
JobRestartException, JobInstanceAlreadyCompleteException, InvalidJobParametersException {
190190
JobExecution execution = this.jobOperator.start(job, jobParameters);
191191
if (this.publisher != null) {
192192
this.publisher.publishEvent(new JobExecutionEvent(execution));

module/spring-boot-batch/src/test/java/org/springframework/boot/batch/autoconfigure/JobExecutionExitCodeGeneratorTests.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import org.springframework.batch.core.BatchStatus;
2222
import org.springframework.batch.core.job.JobExecution;
23+
import org.springframework.batch.core.job.JobInstance;
24+
import org.springframework.batch.core.job.parameters.JobParameters;
2325

2426
import static org.assertj.core.api.Assertions.assertThat;
2527

@@ -34,24 +36,29 @@ class JobExecutionExitCodeGeneratorTests {
3436

3537
@Test
3638
void testExitCodeForRunning() {
37-
this.generator.onApplicationEvent(new JobExecutionEvent(new JobExecution(0L)));
39+
this.generator.onApplicationEvent(new JobExecutionEvent(testJobExecution()));
3840
assertThat(this.generator.getExitCode()).isOne();
3941
}
4042

4143
@Test
4244
void testExitCodeForCompleted() {
43-
JobExecution execution = new JobExecution(0L);
45+
JobExecution execution = testJobExecution();
4446
execution.setStatus(BatchStatus.COMPLETED);
4547
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
4648
assertThat(this.generator.getExitCode()).isZero();
4749
}
4850

4951
@Test
5052
void testExitCodeForFailed() {
51-
JobExecution execution = new JobExecution(0L);
53+
JobExecution execution = testJobExecution();
5254
execution.setStatus(BatchStatus.FAILED);
5355
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
5456
assertThat(this.generator.getExitCode()).isEqualTo(5);
5557
}
5658

59+
private static JobExecution testJobExecution() {
60+
JobInstance jobInstance = new JobInstance(1L, "job");
61+
return new JobExecution(0L, jobInstance, new JobParameters());
62+
}
63+
5764
}

module/spring-boot-batch/src/test/java/org/springframework/boot/batch/autoconfigure/JobLauncherApplicationRunnerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.springframework.batch.core.step.Step;
3434
import org.springframework.batch.core.step.builder.StepBuilder;
3535
import org.springframework.batch.core.step.tasklet.Tasklet;
36-
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
36+
import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager;
3737
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3838
import org.springframework.context.ApplicationContext;
3939
import org.springframework.context.annotation.Configuration;

platform/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ bom {
23722372
releaseNotes("https://github.com/spring-projects/spring-amqp/releases/tag/v{version}")
23732373
}
23742374
}
2375-
library("Spring Batch", "6.0.0-M3") {
2375+
library("Spring Batch", "6.0.0-SNAPSHOT") {
23762376
considerSnapshots()
23772377
group("org.springframework.batch") {
23782378
bom("spring-batch-bom")

smoke-test/spring-boot-smoke-test-batch-jdbc/src/main/java/smoketest/batch/SampleBatchApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.springframework.batch.core.step.Step;
2323
import org.springframework.batch.core.step.builder.StepBuilder;
2424
import org.springframework.batch.core.step.tasklet.Tasklet;
25-
import org.springframework.batch.repeat.RepeatStatus;
25+
import org.springframework.batch.infrastructure.repeat.RepeatStatus;
2626
import org.springframework.boot.SpringApplication;
2727
import org.springframework.boot.autoconfigure.SpringBootApplication;
2828
import org.springframework.context.annotation.Bean;

smoke-test/spring-boot-smoke-test-batch/src/main/java/smoketest/batch/SampleBatchApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.springframework.batch.core.step.Step;
2323
import org.springframework.batch.core.step.builder.StepBuilder;
2424
import org.springframework.batch.core.step.tasklet.Tasklet;
25-
import org.springframework.batch.repeat.RepeatStatus;
25+
import org.springframework.batch.infrastructure.repeat.RepeatStatus;
2626
import org.springframework.boot.SpringApplication;
2727
import org.springframework.boot.autoconfigure.SpringBootApplication;
2828
import org.springframework.context.annotation.Bean;

0 commit comments

Comments
 (0)