Skip to content

Commit 363196e

Browse files
committed
Revert "Add JSpecify nullability annotations to Spring Cloud Task"
This reverts commit 7532ed8.
1 parent 7532ed8 commit 363196e

File tree

82 files changed

+299
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+299
-606
lines changed

.mvn/jvm.config

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
11
-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom
2-
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
3-
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
4-
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
5-
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
6-
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
7-
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
8-
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
9-
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
10-
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
11-
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

.mvn/maven.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local
2-
-Djspecify.enabled=true
32
-P spring

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/RangeConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.cloud.task.batch.autoconfigure;
1818

19-
import org.jspecify.annotations.Nullable;
20-
2119
import org.springframework.batch.infrastructure.item.file.transform.Range;
2220
import org.springframework.core.convert.converter.Converter;
2321

@@ -33,7 +31,7 @@
3331
public class RangeConverter implements Converter<String, Range> {
3432

3533
@Override
36-
public @Nullable Range convert(String source) {
34+
public Range convert(String source) {
3735
if (source == null) {
3836
return null;
3937
}

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/SingleStepJobAutoConfiguration.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import org.springframework.batch.core.job.builder.JobBuilder;
2323
import org.springframework.batch.core.repository.JobRepository;
2424
import org.springframework.batch.core.step.Step;
25-
import org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder;
25+
import org.springframework.batch.core.step.builder.SimpleStepBuilder;
26+
import org.springframework.batch.core.step.builder.StepBuilder;
2627
import org.springframework.batch.infrastructure.item.ItemProcessor;
2728
import org.springframework.batch.infrastructure.item.ItemReader;
2829
import org.springframework.batch.infrastructure.item.ItemWriter;
@@ -77,16 +78,16 @@ private void validateProperties(SingleStepJobProperties properties) {
7778
@ConditionalOnMissingBean
7879
@ConditionalOnProperty(prefix = "spring.batch.job", name = "job-name")
7980
public Job job(ItemReader<Map<String, Object>> itemReader, ItemWriter<Map<String, Object>> itemWriter) {
80-
Assert.state(properties.getStepName() != null, "A step name is required");
81-
Assert.state(properties.getChunkSize() != null, "A chunkSize is required");
82-
var chunkOrientedStepBuilder = new ChunkOrientedStepBuilder(properties.getStepName(), this.jobRepository,
83-
this.properties.getChunkSize())
84-
.transactionManager(this.transactionManager)
81+
82+
SimpleStepBuilder<Map<String, Object>, Map<String, Object>> stepBuilder = new StepBuilder(
83+
this.properties.getStepName(), this.jobRepository)
84+
.<Map<String, Object>, Map<String, Object>>chunk(this.properties.getChunkSize(), this.transactionManager)
8585
.reader(itemReader);
86-
chunkOrientedStepBuilder.processor(this.itemProcessor);
87-
Step step = chunkOrientedStepBuilder.writer(itemWriter).build();
8886

89-
Assert.state(this.properties.getJobName() != null, "A job name is required");
87+
stepBuilder.processor(this.itemProcessor);
88+
89+
Step step = stepBuilder.writer(itemWriter).build();
90+
9091
return new JobBuilder(this.properties.getJobName(), this.jobRepository).start(step).build();
9192
}
9293

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/SingleStepJobProperties.java

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

1717
package org.springframework.cloud.task.batch.autoconfigure;
1818

19-
import org.jspecify.annotations.Nullable;
20-
2119
import org.springframework.boot.context.properties.ConfigurationProperties;
2220

2321
/**
@@ -32,63 +30,63 @@ public class SingleStepJobProperties {
3230
/**
3331
* Name of the step in the single step job.
3432
*/
35-
private @Nullable String stepName;
33+
private String stepName;
3634

3735
/**
3836
* The number of items to process per transaction or chunk.
3937
*/
40-
private @Nullable Integer chunkSize;
38+
private Integer chunkSize;
4139

4240
/**
4341
* The name of the job.
4442
*/
45-
private @Nullable String jobName;
43+
private String jobName;
4644

4745
/**
4846
* Name of the step in the single step job.
4947
* @return name
5048
*/
51-
public @Nullable String getStepName() {
49+
public String getStepName() {
5250
return stepName;
5351
}
5452

5553
/**
5654
* Set the name of the step.
5755
* @param stepName name
5856
*/
59-
public void setStepName(@Nullable String stepName) {
57+
public void setStepName(String stepName) {
6058
this.stepName = stepName;
6159
}
6260

6361
/**
6462
* The number of items to process per transaction/chunk.
6563
* @return number of items
6664
*/
67-
public @Nullable Integer getChunkSize() {
65+
public Integer getChunkSize() {
6866
return chunkSize;
6967
}
7068

7169
/**
7270
* Set the number of items within a transaction/chunk.
7371
* @param chunkSize number of items
7472
*/
75-
public void setChunkSize(@Nullable Integer chunkSize) {
73+
public void setChunkSize(Integer chunkSize) {
7674
this.chunkSize = chunkSize;
7775
}
7876

7977
/**
8078
* The name of the job.
8179
* @return name
8280
*/
83-
public @Nullable String getJobName() {
81+
public String getJobName() {
8482
return jobName;
8583
}
8684

8785
/**
8886
* Set the name of the job.
8987
* @param jobName name
9088
*/
91-
public void setJobName(@Nullable String jobName) {
89+
public void setJobName(String jobName) {
9290
this.jobName = jobName;
9391
}
9492

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/flatfile/FlatFileItemReaderAutoConfiguration.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4343
import org.springframework.cloud.task.batch.autoconfigure.RangeConverter;
4444
import org.springframework.context.annotation.Bean;
45-
import org.springframework.util.Assert;
4645

4746
/**
4847
* Autconfiguration for a {@code FlatFileItemReader}.
@@ -72,8 +71,6 @@ public FlatFileItemReader<Map<String, Object>> itemReader(@Autowired(required =
7271
@Autowired(required = false) LineMapper<Map<String, Object>> lineMapper,
7372
@Autowired(required = false) LineCallbackHandler skippedLinesCallback,
7473
@Autowired(required = false) RecordSeparatorPolicy recordSeparatorPolicy) {
75-
Assert.state(this.properties.getName() != null, "A name is required");
76-
Assert.state(this.properties.getResource() != null, "A resource is required");
7774
FlatFileItemReaderBuilder<Map<String, Object>> mapFlatFileItemReaderBuilder = new FlatFileItemReaderBuilder<Map<String, Object>>()
7875
.name(this.properties.getName())
7976
.resource(this.properties.getResource())
@@ -93,7 +90,6 @@ public FlatFileItemReader<Map<String, Object>> itemReader(@Autowired(required =
9390
mapFlatFileItemReaderBuilder.skippedLinesCallback(skippedLinesCallback);
9491

9592
if (this.properties.isDelimited()) {
96-
Assert.state(this.properties.getNames() != null, "Names are required");
9793
mapFlatFileItemReaderBuilder.delimited()
9894
.quoteCharacter(this.properties.getQuoteCharacter())
9995
.delimiter(this.properties.getDelimiter())
@@ -103,14 +99,9 @@ public FlatFileItemReader<Map<String, Object>> itemReader(@Autowired(required =
10399
.fieldSetMapper(new MapFieldSetMapper());
104100
}
105101
else if (this.properties.isFixedLength()) {
106-
Assert.state(this.properties.getNames() != null, "Names are required");
107102
RangeConverter rangeConverter = new RangeConverter();
108103
List<Range> ranges = new ArrayList<>();
109-
this.properties.getRanges().forEach(range -> {
110-
Range result = rangeConverter.convert(range);
111-
Assert.state(result != null, "Range String could not converted to non-null range");
112-
ranges.add(result);
113-
});
104+
this.properties.getRanges().forEach(range -> ranges.add(rangeConverter.convert(range)));
114105
mapFlatFileItemReaderBuilder.fixedLength()
115106
.columns(ranges.toArray(new Range[0]))
116107
.names(this.properties.getNames())

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/flatfile/FlatFileItemReaderProperties.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
import org.jspecify.annotations.Nullable;
23-
2422
import org.springframework.batch.infrastructure.item.file.FlatFileItemReader;
2523
import org.springframework.batch.infrastructure.item.file.transform.DelimitedLineTokenizer;
2624
import org.springframework.batch.infrastructure.item.file.transform.Range;
@@ -46,7 +44,7 @@ public class FlatFileItemReaderProperties {
4644
* {@link org.springframework.batch.infrastructure.item.ExecutionContext}. Required if
4745
* {@link #setSaveState} is set to {@code true}.
4846
*/
49-
private @Nullable String name;
47+
private String name;
5048

5149
/**
5250
* Configure the maximum number of items to be read.
@@ -66,7 +64,7 @@ public class FlatFileItemReaderProperties {
6664
/**
6765
* The {@link Resource} to be used as input.
6866
*/
69-
private @Nullable Resource resource;
67+
private Resource resource;
7068

7169
/**
7270
* Configure whether the reader should be in strict mode (require the input
@@ -120,7 +118,7 @@ public class FlatFileItemReaderProperties {
120118
/**
121119
* The names of the fields to be parsed from the file.
122120
*/
123-
private String @Nullable [] names;
121+
private String[] names;
124122

125123
/**
126124
* Indicates whether the number of tokens must match the number of configured fields.
@@ -152,7 +150,7 @@ public void setSaveState(boolean saveState) {
152150
* keys.
153151
* @return the name
154152
*/
155-
public @Nullable String getName() {
153+
public String getName() {
156154
return this.name;
157155
}
158156

@@ -163,7 +161,7 @@ public void setSaveState(boolean saveState) {
163161
* @param name name of the reader instance
164162
* @see org.springframework.batch.infrastructure.item.ItemStreamSupport#setName(String)
165163
*/
166-
public void setName(@Nullable String name) {
164+
public void setName(String name) {
167165
this.name = name;
168166
}
169167

@@ -221,7 +219,7 @@ public void setComments(List<String> comments) {
221219
* The input file for the {@code FlatFileItemReader}.
222220
* @return a Resource
223221
*/
224-
public @Nullable Resource getResource() {
222+
public Resource getResource() {
225223
return this.resource;
226224
}
227225

@@ -230,7 +228,7 @@ public void setComments(List<String> comments) {
230228
* @param resource the input to the reader.
231229
* @see FlatFileItemReader#setResource(Resource)
232230
*/
233-
public void setResource(@Nullable Resource resource) {
231+
public void setResource(Resource resource) {
234232
this.resource = resource;
235233
}
236234

@@ -393,15 +391,15 @@ public void setRanges(List<String> ranges) {
393391
* Names of each column.
394392
* @return names
395393
*/
396-
public String @Nullable [] getNames() {
394+
public String[] getNames() {
397395
return this.names;
398396
}
399397

400398
/**
401399
* The names of the fields to be parsed from the file.
402400
* @param names names of fields
403401
*/
404-
public void setNames(String @Nullable [] names) {
402+
public void setNames(String[] names) {
405403
this.names = names;
406404
}
407405

spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/flatfile/FlatFileItemWriterAutoConfiguration.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3636
import org.springframework.context.annotation.Bean;
3737
import org.springframework.core.io.WritableResource;
38-
import org.springframework.util.Assert;
3938

4039
/**
4140
* Autoconfiguration for a {@code FlatFileItemWriter}.
@@ -48,7 +47,7 @@
4847
@AutoConfigureAfter(BatchAutoConfiguration.class)
4948
public class FlatFileItemWriterAutoConfiguration {
5049

51-
private final FlatFileItemWriterProperties properties;
50+
private FlatFileItemWriterProperties properties;
5251

5352
@Autowired(required = false)
5453
private LineAggregator<Map<String, Object>> lineAggregator;
@@ -79,8 +78,7 @@ else if ((this.properties.isFormatted() || this.properties.isDelimited()) && thi
7978
throw new IllegalStateException(
8079
"A LineAggregator must be configured if the " + "output is not formatted or delimited");
8180
}
82-
Assert.state(this.properties.getName() != null, "name must not be null");
83-
Assert.state(this.properties.getResource() != null, "resource must not be null");
81+
8482
FlatFileItemWriterBuilder<Map<String, Object>> builder = new FlatFileItemWriterBuilder<Map<String, Object>>()
8583
.name(this.properties.getName())
8684
.resource((WritableResource) this.properties.getResource())
@@ -103,13 +101,10 @@ else if ((this.properties.isFormatted() || this.properties.isDelimited()) && thi
103101
delimitedBuilder.fieldExtractor(this.fieldExtractor);
104102
}
105103
else {
106-
Assert.state(this.properties.getNames() != null, "names must not be null");
107104
delimitedBuilder.fieldExtractor(new MapFieldExtractor(this.properties.getNames()));
108105
}
109106
}
110107
else if (this.properties.isFormatted()) {
111-
Assert.state(this.properties.getFormat() != null, "format must not be null");
112-
113108
FlatFileItemWriterBuilder.FormattedBuilder<Map<String, Object>> formattedBuilder = builder.formatted()
114109
.format(this.properties.getFormat())
115110
.locale(this.properties.getLocale())
@@ -120,7 +115,6 @@ else if (this.properties.isFormatted()) {
120115
formattedBuilder.fieldExtractor(this.fieldExtractor);
121116
}
122117
else {
123-
Assert.state(this.properties.getNames() != null, "names must not be null");
124118
formattedBuilder.fieldExtractor(new MapFieldExtractor(this.properties.getNames()));
125119
}
126120
}
@@ -137,7 +131,7 @@ else if (this.lineAggregator != null) {
137131
*/
138132
public static class MapFieldExtractor implements FieldExtractor<Map<String, Object>> {
139133

140-
private final String[] names;
134+
private String[] names;
141135

142136
public MapFieldExtractor(String[] names) {
143137
this.names = names;

0 commit comments

Comments
 (0)