Skip to content

Commit c65b93f

Browse files
committed
Add non null assertions in Job/Step builder factories
1 parent a346f14 commit c65b93f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/JobBuilderFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.springframework.batch.core.job.builder.JobBuilder;
1919
import org.springframework.batch.core.repository.JobRepository;
20+
import org.springframework.util.Assert;
2021

2122
/**
2223
* Convenient factory for a {@link JobBuilder} which sets the {@link JobRepository}
@@ -32,8 +33,10 @@ public class JobBuilderFactory {
3233

3334
/**
3435
* @param jobRepository The {@link JobRepository} to be used by the builder factory.
36+
* Must not be {@code null}.
3537
*/
3638
public JobBuilderFactory(JobRepository jobRepository) {
39+
Assert.notNull(jobRepository, "JobRepository must not be null");
3740
this.jobRepository = jobRepository;
3841
}
3942

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/StepBuilderFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.springframework.batch.core.repository.JobRepository;
1919
import org.springframework.batch.core.step.builder.StepBuilder;
2020
import org.springframework.transaction.PlatformTransactionManager;
21+
import org.springframework.util.Assert;
2122

2223
/**
2324
* Convenient factory for a {@link StepBuilder} which sets the {@link JobRepository} and
@@ -36,10 +37,13 @@ public class StepBuilderFactory {
3637
/**
3738
* Constructor for the {@link StepBuilderFactory}.
3839
* @param jobRepository The {@link JobRepository} to be used by the builder factory.
40+
* Must not be {@code null}.
3941
* @param transactionManager The {@link PlatformTransactionManager} to be used by the
40-
* builder factory.
42+
* builder factory. Must not be {@code null}.
4143
*/
4244
public StepBuilderFactory(JobRepository jobRepository, PlatformTransactionManager transactionManager) {
45+
Assert.notNull(jobRepository, "JobRepository must not be null");
46+
Assert.notNull(transactionManager, "transactionManager must not be null");
4347
this.jobRepository = jobRepository;
4448
this.transactionManager = transactionManager;
4549
}

0 commit comments

Comments
 (0)