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
This commit is contained in:
Stéphane Nicoll
2025-10-10 18:28:59 +02:00
6 changed files with 24 additions and 17 deletions
@@ -31,13 +31,12 @@ import org.springframework.batch.core.converter.JobParametersConverter;
import org.springframework.batch.core.job.Job;
import org.springframework.batch.core.job.JobExecution;
import org.springframework.batch.core.job.JobExecutionException;
import org.springframework.batch.core.job.parameters.InvalidJobParametersException;
import org.springframework.batch.core.job.parameters.JobParameters;
import org.springframework.batch.core.job.parameters.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.core.launch.JobRestartException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
@@ -146,10 +145,11 @@ public class JobLauncherApplicationRunner
public void run(String... args) throws JobExecutionException {
logger.info("Running default command line with: " + Arrays.asList(args));
launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="));
Properties properties = StringUtils.splitArrayElementsIntoProperties(args, "=");
launchJobFromProperties((properties != null) ? properties : new Properties());
}
protected void launchJobFromProperties(@Nullable Properties properties) throws JobExecutionException {
protected void launchJobFromProperties(Properties properties) throws JobExecutionException {
JobParameters jobParameters = this.converter.getJobParameters(properties);
executeLocalJobs(jobParameters);
executeRegisteredJobs(jobParameters);
@@ -179,14 +179,14 @@ public class JobLauncherApplicationRunner
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) {
if (!isLocalJob(this.jobName)) {
Job job = this.jobRegistry.getJob(this.jobName);
Assert.notNull(job, () -> "No job found with name '" + this.jobName + "'");
execute(job, jobParameters);
}
}
}
protected void execute(Job job, JobParameters jobParameters)
throws JobExecutionAlreadyRunningException, NoSuchJobException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException {
protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException, InvalidJobParametersException {
JobExecution execution = this.jobOperator.start(job, jobParameters);
if (this.publisher != null) {
this.publisher.publishEvent(new JobExecutionEvent(execution));
@@ -20,6 +20,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.job.JobExecution;
import org.springframework.batch.core.job.JobInstance;
import org.springframework.batch.core.job.parameters.JobParameters;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,13 +36,13 @@ class JobExecutionExitCodeGeneratorTests {
@Test
void testExitCodeForRunning() {
this.generator.onApplicationEvent(new JobExecutionEvent(new JobExecution(0L)));
this.generator.onApplicationEvent(new JobExecutionEvent(testJobExecution()));
assertThat(this.generator.getExitCode()).isOne();
}
@Test
void testExitCodeForCompleted() {
JobExecution execution = new JobExecution(0L);
JobExecution execution = testJobExecution();
execution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isZero();
@@ -48,10 +50,15 @@ class JobExecutionExitCodeGeneratorTests {
@Test
void testExitCodeForFailed() {
JobExecution execution = new JobExecution(0L);
JobExecution execution = testJobExecution();
execution.setStatus(BatchStatus.FAILED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isEqualTo(5);
}
private static JobExecution testJobExecution() {
JobInstance jobInstance = new JobInstance(1L, "job");
return new JobExecution(0L, jobInstance, new JobParameters());
}
}
@@ -33,7 +33,7 @@ import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.Step;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.batch.infrastructure.support.transaction.ResourcelessTransactionManager;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
@@ -2372,7 +2372,7 @@ bom {
releaseNotes("https://github.com/spring-projects/spring-amqp/releases/tag/v{version}")
}
}
library("Spring Batch", "6.0.0-M3") {
library("Spring Batch", "6.0.0-SNAPSHOT") {
considerSnapshots()
group("org.springframework.batch") {
bom("spring-batch-bom")
@@ -22,7 +22,7 @@ import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.Step;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.infrastructure.repeat.RepeatStatus;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@@ -22,7 +22,7 @@ import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.Step;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.infrastructure.repeat.RepeatStatus;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;