Skip to content

Commit 06e9827

Browse files
committed
Add nullability annotations to module/spring-boot-batch
See gh-46587
1 parent 23b902f commit 06e9827

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

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

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

2121
import javax.sql.DataSource;
2222

23+
import org.jspecify.annotations.Nullable;
24+
2325
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2426
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
2527
import org.springframework.batch.core.configuration.support.JdbcDefaultBatchConfiguration;
@@ -103,15 +105,15 @@ static class SpringBootBatchConfiguration extends JdbcDefaultBatchConfiguration
103105

104106
private final PlatformTransactionManager transactionManager;
105107

106-
private final TaskExecutor taskExecutor;
108+
private final @Nullable TaskExecutor taskExecutor;
107109

108110
private final BatchProperties properties;
109111

110112
private final List<BatchConversionServiceCustomizer> batchConversionServiceCustomizers;
111113

112-
private final ExecutionContextSerializer executionContextSerializer;
114+
private final @Nullable ExecutionContextSerializer executionContextSerializer;
113115

114-
private final JobParametersConverter jobParametersConverter;
116+
private final @Nullable JobParametersConverter jobParametersConverter;
115117

116118
SpringBootBatchConfiguration(DataSource dataSource, @BatchDataSource ObjectProvider<DataSource> batchDataSource,
117119
PlatformTransactionManager transactionManager,

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.batch.autoconfigure;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.boot.context.properties.ConfigurationProperties;
2022
import org.springframework.boot.sql.init.DatabaseInitializationMode;
2123
import org.springframework.transaction.annotation.Isolation;
@@ -76,7 +78,7 @@ public static class Jdbc {
7678
/**
7779
* Transaction isolation level to use when creating job meta-data for new jobs.
7880
*/
79-
private Isolation isolationLevelForCreate;
81+
private @Nullable Isolation isolationLevelForCreate;
8082

8183
/**
8284
* Path to the SQL file to use to initialize the database schema.
@@ -87,12 +89,12 @@ public static class Jdbc {
8789
* Platform to use in initialization scripts if the @@platform@@ placeholder is
8890
* used. Auto-detected by default.
8991
*/
90-
private String platform;
92+
private @Nullable String platform;
9193

9294
/**
9395
* Table prefix for all the batch meta-data tables.
9496
*/
95-
private String tablePrefix;
97+
private @Nullable String tablePrefix;
9698

9799
/**
98100
* Database schema initialization mode.
@@ -107,11 +109,11 @@ public void setValidateTransactionState(boolean validateTransactionState) {
107109
this.validateTransactionState = validateTransactionState;
108110
}
109111

110-
public Isolation getIsolationLevelForCreate() {
112+
public @Nullable Isolation getIsolationLevelForCreate() {
111113
return this.isolationLevelForCreate;
112114
}
113115

114-
public void setIsolationLevelForCreate(Isolation isolationLevelForCreate) {
116+
public void setIsolationLevelForCreate(@Nullable Isolation isolationLevelForCreate) {
115117
this.isolationLevelForCreate = isolationLevelForCreate;
116118
}
117119

@@ -123,19 +125,19 @@ public void setSchema(String schema) {
123125
this.schema = schema;
124126
}
125127

126-
public String getPlatform() {
128+
public @Nullable String getPlatform() {
127129
return this.platform;
128130
}
129131

130-
public void setPlatform(String platform) {
132+
public void setPlatform(@Nullable String platform) {
131133
this.platform = platform;
132134
}
133135

134-
public String getTablePrefix() {
136+
public @Nullable String getTablePrefix() {
135137
return this.tablePrefix;
136138
}
137139

138-
public void setTablePrefix(String tablePrefix) {
140+
public void setTablePrefix(@Nullable String tablePrefix) {
139141
this.tablePrefix = tablePrefix;
140142
}
141143

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.apache.commons.logging.Log;
2525
import org.apache.commons.logging.LogFactory;
26+
import org.jspecify.annotations.Nullable;
2627

2728
import org.springframework.batch.core.configuration.JobRegistry;
2829
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
@@ -74,14 +75,15 @@ public class JobLauncherApplicationRunner
7475

7576
private final JobOperator jobOperator;
7677

77-
private JobRegistry jobRegistry;
78+
private @Nullable JobRegistry jobRegistry;
7879

79-
private String jobName;
80+
private @Nullable String jobName;
8081

8182
private Collection<Job> jobs = Collections.emptySet();
8283

8384
private int order = DEFAULT_ORDER;
8485

86+
@SuppressWarnings("NullAway.Init")
8587
private ApplicationEventPublisher publisher;
8688

8789
/**
@@ -147,7 +149,7 @@ public void run(String... args) throws JobExecutionException {
147149
launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "="));
148150
}
149151

150-
protected void launchJobFromProperties(Properties properties) throws JobExecutionException {
152+
protected void launchJobFromProperties(@Nullable Properties properties) throws JobExecutionException {
151153
JobParameters jobParameters = this.converter.getJobParameters(properties);
152154
executeLocalJobs(jobParameters);
153155
executeRegisteredJobs(jobParameters);

module/spring-boot-batch/src/main/java/org/springframework/boot/batch/autoconfigure/observation/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Spring Batch observations.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.batch.autoconfigure.observation;
22+
23+
import org.jspecify.annotations.NullMarked;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Spring Batch.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.batch.autoconfigure;
22+
23+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)