Skip to content

Commit 07f8034

Browse files
committed
Polish "Remove APIs that were deprecated for removal in 4.2"
See gh-50955
1 parent d4d503b commit 07f8034

11 files changed

Lines changed: 26 additions & 612 deletions

File tree

module/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.reflect.Method;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.junit.jupiter.api.Test;
2223

2324
import org.springframework.boot.actuate.endpoint.annotation.Selector;
@@ -36,8 +37,6 @@ class OperationMethodParameterTests {
3637

3738
private final Method example = findMethod("example", String.class, String.class);
3839

39-
private final Method exampleSpringNullable = findMethod("exampleSpringNullable", String.class, String.class);
40-
4140
private final Method exampleAnnotation = findMethod("exampleAnnotation", String.class);
4241

4342
@Test
@@ -64,14 +63,6 @@ void isMandatoryWhenNullableAnnotationShouldReturnFalse() {
6463
assertThat(parameter.isMandatory()).isFalse();
6564
}
6665

67-
@Test
68-
@Deprecated(since = "4.0.0")
69-
void isMandatoryWhenSpringNullableAnnotationShouldReturnFalse() {
70-
OperationMethodParameter parameter = new OperationMethodParameter("name",
71-
this.exampleSpringNullable.getParameters()[1]);
72-
assertThat(parameter.isMandatory()).isFalse();
73-
}
74-
7566
@Test
7667
void getAnnotationShouldReturnAnnotation() {
7768
OperationMethodParameter parameter = new OperationMethodParameter("name",
@@ -87,11 +78,7 @@ private Method findMethod(String name, Class<?>... parameters) {
8778
return method;
8879
}
8980

90-
void example(String one, @org.jspecify.annotations.Nullable String two) {
91-
}
92-
93-
@Deprecated(since = "4.0.0")
94-
void exampleSpringNullable(String one, @org.springframework.lang.Nullable String two) {
81+
void example(String one, @Nullable String two) {
9582
}
9683

9784
void exampleAnnotation(@Selector(match = Match.ALL_REMAINING) String allRemaining) {

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2626
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
2727
import org.springframework.batch.core.configuration.support.JdbcDefaultBatchConfiguration;
28-
import org.springframework.batch.core.converter.JobParametersConverter;
2928
import org.springframework.batch.core.launch.JobOperator;
3029
import org.springframework.batch.core.repository.ExecutionContextSerializer;
3130
import org.springframework.beans.factory.ObjectProvider;
@@ -91,23 +90,19 @@ static class SpringBootBatchJdbcConfiguration extends JdbcDefaultBatchConfigurat
9190

9291
private final @Nullable ExecutionContextSerializer executionContextSerializer;
9392

94-
private final @Nullable JobParametersConverter jobParametersConverter;
95-
9693
SpringBootBatchJdbcConfiguration(DataSource dataSource,
9794
@BatchDataSource ObjectProvider<DataSource> batchDataSource,
9895
PlatformTransactionManager transactionManager,
9996
@BatchTransactionManager ObjectProvider<PlatformTransactionManager> batchTransactionManager,
10097
@BatchTaskExecutor ObjectProvider<TaskExecutor> batchTaskExecutor, BatchJdbcProperties properties,
10198
ObjectProvider<BatchConversionServiceCustomizer> batchConversionServiceCustomizers,
102-
ObjectProvider<ExecutionContextSerializer> executionContextSerializer,
103-
ObjectProvider<JobParametersConverter> jobParametersConverter) {
99+
ObjectProvider<ExecutionContextSerializer> executionContextSerializer) {
104100
this.dataSource = batchDataSource.getIfAvailable(() -> dataSource);
105101
this.transactionManager = batchTransactionManager.getIfAvailable(() -> transactionManager);
106102
this.taskExecutor = batchTaskExecutor.getIfAvailable();
107103
this.properties = properties;
108104
this.batchConversionServiceCustomizers = batchConversionServiceCustomizers.orderedStream().toList();
109105
this.executionContextSerializer = executionContextSerializer.getIfAvailable();
110-
this.jobParametersConverter = jobParametersConverter.getIfAvailable();
111106
}
112107

113108
@Override
@@ -152,14 +147,6 @@ protected ExecutionContextSerializer getExecutionContextSerializer() {
152147
: super.getExecutionContextSerializer();
153148
}
154149

155-
@Override
156-
@Deprecated(since = "4.0.0", forRemoval = true)
157-
@SuppressWarnings("removal")
158-
protected JobParametersConverter getJobParametersConverter() {
159-
return (this.jobParametersConverter != null) ? this.jobParametersConverter
160-
: super.getJobParametersConverter();
161-
}
162-
163150
@Override
164151
protected TaskExecutor getTaskExecutor() {
165152
return (this.taskExecutor != null) ? this.taskExecutor : super.getTaskExecutor();

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
import org.springframework.batch.core.configuration.JobRegistry;
3232
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
3333
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
34-
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
35-
import org.springframework.batch.core.converter.JobParametersConverter;
36-
import org.springframework.batch.core.converter.JsonJobParametersConverter;
3734
import org.springframework.batch.core.job.AbstractJob;
3835
import org.springframework.batch.core.job.Job;
3936
import org.springframework.batch.core.job.JobExecution;
@@ -514,31 +511,6 @@ void customJdbcPropertiesIsUsed() {
514511

515512
}
516513

517-
@Test
518-
@Deprecated(since = "4.0.0", forRemoval = true)
519-
@SuppressWarnings("removal")
520-
void customJobParametersConverterIsUsed() {
521-
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
522-
.withBean(JobParametersConverter.class, JsonJobParametersConverter::new)
523-
.withPropertyValues("spring.datasource.generate-unique-name=true")
524-
.run((context) -> {
525-
assertThat(context).hasSingleBean(JsonJobParametersConverter.class);
526-
assertThat(context.getBean(SpringBootBatchJdbcConfiguration.class).getJobParametersConverter())
527-
.isInstanceOf(JsonJobParametersConverter.class);
528-
});
529-
}
530-
531-
@Test
532-
@Deprecated(since = "4.0.0", forRemoval = true)
533-
@SuppressWarnings("removal")
534-
void defaultJobParametersConverterIsUsed() {
535-
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
536-
assertThat(context).doesNotHaveBean(JobParametersConverter.class);
537-
assertThat(context.getBean(SpringBootBatchJdbcConfiguration.class).getJobParametersConverter())
538-
.isInstanceOf(DefaultJobParametersConverter.class);
539-
});
540-
}
541-
542514
private JobLauncherApplicationRunner createInstance(String... registeredJobNames) {
543515
JobLauncherApplicationRunner runner = new JobLauncherApplicationRunner(mock(JobOperator.class));
544516
JobRegistry jobRegistry = mock(JobRegistry.class);

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2222
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
23-
import org.springframework.batch.core.converter.JobParametersConverter;
2423
import org.springframework.batch.core.launch.JobOperator;
2524
import org.springframework.beans.factory.ObjectProvider;
2625
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -49,20 +48,8 @@ static class SpringBootBatchDefaultConfiguration extends DefaultBatchConfigurati
4948

5049
private final @Nullable TaskExecutor taskExecutor;
5150

52-
private final @Nullable JobParametersConverter jobParametersConverter;
53-
54-
SpringBootBatchDefaultConfiguration(@BatchTaskExecutor ObjectProvider<TaskExecutor> batchTaskExecutor,
55-
ObjectProvider<JobParametersConverter> jobParametersConverter) {
51+
SpringBootBatchDefaultConfiguration(@BatchTaskExecutor ObjectProvider<TaskExecutor> batchTaskExecutor) {
5652
this.taskExecutor = batchTaskExecutor.getIfAvailable();
57-
this.jobParametersConverter = jobParametersConverter.getIfAvailable();
58-
}
59-
60-
@Override
61-
@Deprecated(since = "4.0.0", forRemoval = true)
62-
@SuppressWarnings("removal")
63-
protected JobParametersConverter getJobParametersConverter() {
64-
return (this.jobParametersConverter != null) ? this.jobParametersConverter
65-
: super.getJobParametersConverter();
6653
}
6754

6855
@Override

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import org.springframework.batch.core.configuration.JobRegistry;
2626
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2727
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
28-
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
29-
import org.springframework.batch.core.converter.JobParametersConverter;
30-
import org.springframework.batch.core.converter.JsonJobParametersConverter;
3128
import org.springframework.batch.core.job.Job;
3229
import org.springframework.batch.core.launch.JobOperator;
3330
import org.springframework.batch.core.repository.JobRepository;
@@ -135,28 +132,6 @@ void whenTheUserDefinesAJobNameThatDoesNotExistWithRegisteredJobFailsFast() {
135132
.withMessage("No job found with name 'three'");
136133
}
137134

138-
@Test
139-
@Deprecated(since = "4.0.0", forRemoval = true)
140-
@SuppressWarnings("removal")
141-
void customJobParametersConverterIsUsed() {
142-
this.contextRunner.withBean(JobParametersConverter.class, JsonJobParametersConverter::new).run((context) -> {
143-
assertThat(context).hasSingleBean(JsonJobParametersConverter.class);
144-
assertThat(context.getBean(SpringBootBatchDefaultConfiguration.class).getJobParametersConverter())
145-
.isInstanceOf(JsonJobParametersConverter.class);
146-
});
147-
}
148-
149-
@Test
150-
@Deprecated(since = "4.0.0", forRemoval = true)
151-
@SuppressWarnings("removal")
152-
void defaultJobParametersConverterIsUsed() {
153-
this.contextRunner.run((context) -> {
154-
assertThat(context).doesNotHaveBean(JobParametersConverter.class);
155-
assertThat(context.getBean(SpringBootBatchDefaultConfiguration.class).getJobParametersConverter())
156-
.isInstanceOf(DefaultJobParametersConverter.class);
157-
});
158-
}
159-
160135
private JobLauncherApplicationRunner createInstance(String... registeredJobNames) {
161136
JobLauncherApplicationRunner runner = new JobLauncherApplicationRunner(mock(JobOperator.class));
162137
JobRegistry jobRegistry = mock(JobRegistry.class);

module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/DefaultClientHttpMessageConvertersCustomizer.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,29 @@
1818

1919
import java.util.Collection;
2020

21-
import org.jspecify.annotations.Nullable;
22-
2321
import org.springframework.http.converter.HttpMessageConverter;
2422
import org.springframework.http.converter.HttpMessageConverters.ClientBuilder;
2523
import org.springframework.http.converter.json.KotlinSerializationJsonHttpMessageConverter;
2624

27-
@SuppressWarnings("deprecation")
2825
class DefaultClientHttpMessageConvertersCustomizer implements ClientHttpMessageConvertersCustomizer {
2926

30-
private final @Nullable HttpMessageConverters legacyConverters;
31-
3227
private final Collection<HttpMessageConverter<?>> converters;
3328

34-
DefaultClientHttpMessageConvertersCustomizer(@Nullable HttpMessageConverters legacyConverters,
35-
Collection<HttpMessageConverter<?>> converters) {
36-
this.legacyConverters = legacyConverters;
29+
DefaultClientHttpMessageConvertersCustomizer(Collection<HttpMessageConverter<?>> converters) {
3730
this.converters = converters;
3831
}
3932

4033
@Override
4134
public void customize(ClientBuilder builder) {
42-
if (this.legacyConverters != null) {
43-
this.legacyConverters.forEach(builder::addCustomConverter);
44-
}
45-
else {
46-
builder.registerDefaults();
47-
this.converters.forEach((converter) -> {
48-
if (converter instanceof KotlinSerializationJsonHttpMessageConverter) {
49-
builder.withKotlinSerializationJsonConverter(converter);
50-
}
51-
else {
52-
builder.addCustomConverter(converter);
53-
}
54-
});
55-
}
35+
builder.registerDefaults();
36+
this.converters.forEach((converter) -> {
37+
if (converter instanceof KotlinSerializationJsonHttpMessageConverter) {
38+
builder.withKotlinSerializationJsonConverter(converter);
39+
}
40+
else {
41+
builder.addCustomConverter(converter);
42+
}
43+
});
5644
}
5745

5846
}

module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/DefaultServerHttpMessageConvertersCustomizer.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,29 @@
1818

1919
import java.util.Collection;
2020

21-
import org.jspecify.annotations.Nullable;
22-
2321
import org.springframework.http.converter.HttpMessageConverter;
2422
import org.springframework.http.converter.HttpMessageConverters.ServerBuilder;
2523
import org.springframework.http.converter.json.KotlinSerializationJsonHttpMessageConverter;
2624

27-
@SuppressWarnings("deprecation")
2825
class DefaultServerHttpMessageConvertersCustomizer implements ServerHttpMessageConvertersCustomizer {
2926

30-
private final @Nullable HttpMessageConverters legacyConverters;
31-
3227
private final Collection<HttpMessageConverter<?>> converters;
3328

34-
DefaultServerHttpMessageConvertersCustomizer(@Nullable HttpMessageConverters legacyConverters,
35-
Collection<HttpMessageConverter<?>> converters) {
36-
37-
this.legacyConverters = legacyConverters;
29+
DefaultServerHttpMessageConvertersCustomizer(Collection<HttpMessageConverter<?>> converters) {
3830
this.converters = converters;
3931
}
4032

4133
@Override
4234
public void customize(ServerBuilder builder) {
43-
if (this.legacyConverters != null) {
44-
this.legacyConverters.forEach(builder::addCustomConverter);
45-
}
46-
else {
47-
builder.registerDefaults();
48-
this.converters.forEach((converter) -> {
49-
if (converter instanceof KotlinSerializationJsonHttpMessageConverter) {
50-
builder.withKotlinSerializationJsonConverter(converter);
51-
}
52-
else {
53-
builder.addCustomConverter(converter);
54-
}
55-
});
56-
}
35+
builder.registerDefaults();
36+
this.converters.forEach((converter) -> {
37+
if (converter instanceof KotlinSerializationJsonHttpMessageConverter) {
38+
builder.withKotlinSerializationJsonConverter(converter);
39+
}
40+
else {
41+
builder.addCustomConverter(converter);
42+
}
43+
});
5744
}
5845

5946
}

0 commit comments

Comments
 (0)