Browse Source

Remove APIs that were deprecated for removal in 3.4.0

Closes gh-41435
pull/41443/head
Andy Wilkinson 2 years ago
parent
commit
375b3b16a0
  1. 63
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthContributorAutoConfiguration.java
  2. 20
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/package-info.java
  3. 1
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  4. 55
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthContributorAutoConfigurationTests.java
  5. 53
      spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicator.java
  6. 20
      spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/influx/package-info.java
  7. 67
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java
  8. 2
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
  9. 71
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java
  10. 41
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbCustomizer.java
  11. 38
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbOkHttpClientBuilderProvider.java
  12. 81
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbProperties.java
  13. 20
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/package-info.java
  14. 17
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java
  15. 3
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java
  16. 59
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
  17. 3
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java
  18. 1
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java
  19. 51
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations.java
  20. 3
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java
  21. 47
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingConfigurations.java
  22. 37
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java
  23. 29
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java
  24. 6
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JndiJtaConfiguration.java
  25. 7
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java
  26. 24
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java
  27. 28
      spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  28. 1
      spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  29. 114
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfigurationTests.java
  30. 122
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java
  31. 40
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java
  32. 6
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizersTests.java
  33. 13
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java
  34. 6
      spring-boot-project/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc
  35. 4
      spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/endpoints.adoc
  36. 7
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcConfiguration.java
  37. 5
      spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java
  38. 50
      spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/BeforeTestcontainersPropertySuppliedEvent.java
  39. 4
      spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java
  40. 4
      spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceTests.java
  41. 8
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java
  42. 27
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/pom.xml
  43. 1
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/additional-elements/another/two.txt
  44. 1
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/additional-elements/one.txt
  45. 45
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/java/org/test/SampleApplication.java
  46. 21
      spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
  47. 123
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationContextInitializer.java
  48. 108
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationListener.java
  49. 140
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java
  50. 53
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java
  51. 30
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreBundle.java
  52. 12
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java
  53. 330
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorBuilder.java
  54. 40
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorCustomizer.java
  55. 213
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerBuilder.java
  56. 39
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerCustomizer.java
  57. 56
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactorySettings.java
  58. 17
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java
  59. 6
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriBuilderFactory.java
  60. 50
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java
  61. 15
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java
  62. 11
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java
  63. 2
      spring-boot-project/spring-boot/src/main/resources/META-INF/spring.factories
  64. 8
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java
  65. 123
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/DelegatingApplicationContextInitializerTests.java
  66. 105
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/DelegatingApplicationListenerTests.java
  67. 20
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
  68. 14
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ssl/pem/PemSslStoreBundleTests.java
  69. 169
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java
  70. 135
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java
  71. 5
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriBuilderFactoryTests.java
  72. 18
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java

63
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthContributorAutoConfiguration.java

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.influx;
import java.util.Map;
import org.influxdb.InfluxDB;
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.health.HealthContributor;
import org.springframework.boot.actuate.influx.InfluxDbHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration;
import org.springframework.context.annotation.Bean;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDbHealthIndicator}.
*
* @author Eddú Meléndez
* @since 2.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new client</a> and its own
* Spring Boot integration.
*/
@SuppressWarnings("removal")
@AutoConfiguration(after = InfluxDbAutoConfiguration.class)
@ConditionalOnClass(InfluxDB.class)
@ConditionalOnBean(InfluxDB.class)
@ConditionalOnEnabledHealthIndicator("influxdb")
@Deprecated(since = "3.2.0", forRemoval = true)
public class InfluxDbHealthContributorAutoConfiguration
extends CompositeHealthContributorConfiguration<InfluxDbHealthIndicator, InfluxDB> {
public InfluxDbHealthContributorAutoConfiguration() {
super(InfluxDbHealthIndicator::new);
}
@Bean
@ConditionalOnMissingBean(name = { "influxDbHealthIndicator", "influxDbHealthContributor" })
public HealthContributor influxDbHealthContributor(Map<String, InfluxDB> influxDbs) {
return createContributor(influxDbs);
}
}

20
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/package-info.java

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-configuration for actuator InfluxDB concerns.
*/
package org.springframework.boot.actuate.autoconfigure.influx;

1
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@ -25,7 +25,6 @@ org.springframework.boot.actuate.autoconfigure.flyway.FlywayEndpointAutoConfigur @@ -25,7 +25,6 @@ org.springframework.boot.actuate.autoconfigure.flyway.FlywayEndpointAutoConfigur
org.springframework.boot.actuate.autoconfigure.hazelcast.HazelcastHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.influx.InfluxDbHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.info.InfoContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.integration.IntegrationGraphEndpointAutoConfiguration

55
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthContributorAutoConfigurationTests.java

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.influx;
import org.influxdb.InfluxDB;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
import org.springframework.boot.actuate.influx.InfluxDbHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link InfluxDbHealthContributorAutoConfiguration}.
*
* @author Eddú Meléndez
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.2.0", forRemoval = true)
class InfluxDbHealthContributorAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withBean(InfluxDB.class, () -> mock(InfluxDB.class))
.withConfiguration(AutoConfigurations.of(InfluxDbHealthContributorAutoConfiguration.class,
HealthContributorAutoConfiguration.class));
@Test
void runShouldCreateIndicator() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(InfluxDbHealthIndicator.class));
}
@Test
void runWhenDisabledShouldNotCreateIndicator() {
this.contextRunner.withPropertyValues("management.health.influxdb.enabled:false")
.run((context) -> assertThat(context).doesNotHaveBean(InfluxDbHealthIndicator.class));
}
}

53
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicator.java

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.influx;
import org.influxdb.InfluxDB;
import org.influxdb.dto.Pong;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.util.Assert;
/**
* {@link HealthIndicator} for InfluxDB.
*
* @author Eddú Meléndez
* @since 2.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new client</a> and its own
* Spring Boot integration.
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public class InfluxDbHealthIndicator extends AbstractHealthIndicator {
private final InfluxDB influxDb;
public InfluxDbHealthIndicator(InfluxDB influxDb) {
super("InfluxDB health check failed");
Assert.notNull(influxDb, "InfluxDB must not be null");
this.influxDb = influxDb;
}
@Override
protected void doHealthCheck(Health.Builder builder) {
Pong pong = this.influxDb.ping();
builder.up().withDetail("version", pong.getVersion());
}
}

20
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/influx/package-info.java

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Actuator support for InfluxDB.
*/
package org.springframework.boot.actuate.influx;

67
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.influx;
import java.io.IOException;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBException;
import org.influxdb.dto.Pong;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link InfluxDbHealthIndicator}.
*
* @author Eddú Meléndez
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.2.0", forRemoval = true)
class InfluxDbHealthIndicatorTests {
@Test
void influxDbIsUp() {
Pong pong = mock(Pong.class);
given(pong.getVersion()).willReturn("0.9");
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willReturn(pong);
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("version", "0.9");
then(influxDb).should().ping();
}
@Test
void influxDbIsDown() {
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willThrow(new InfluxDBException(new IOException("Connection failed")));
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
then(influxDb).should().ping();
}
}

2
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java

@ -113,7 +113,7 @@ public class Neo4jDataAutoConfiguration { @@ -113,7 +113,7 @@ public class Neo4jDataAutoConfiguration {
public Neo4jTransactionManager transactionManager(Driver driver, DatabaseSelectionProvider databaseNameProvider,
ObjectProvider<TransactionManagerCustomizers> optionalCustomizers) {
Neo4jTransactionManager transactionManager = new Neo4jTransactionManager(driver, databaseNameProvider);
optionalCustomizers.ifAvailable((customizer) -> customizer.customize((TransactionManager) transactionManager));
optionalCustomizers.ifAvailable((customizer) -> customizer.customize(transactionManager));
return transactionManager;
}

71
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java

@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.influx;
import okhttp3.OkHttpClient;
import org.influxdb.InfluxDB;
import org.influxdb.impl.InfluxDBImpl;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
/**
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB.
*
* @author Sergey Kuptsov
* @author Stephane Nicoll
* @author Eddú Meléndez
* @author Moritz Halbritter
* @author Andy Wilkinson
* @author Phillip Webb
* @since 2.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new client</a> and its own
* Spring Boot integration.
*/
@AutoConfiguration
@ConditionalOnClass(InfluxDB.class)
@EnableConfigurationProperties(InfluxDbProperties.class)
@ConditionalOnProperty("spring.influx.url")
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
public class InfluxDbAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public InfluxDB influxDb(InfluxDbProperties properties, ObjectProvider<InfluxDbOkHttpClientBuilderProvider> builder,
ObjectProvider<InfluxDbCustomizer> customizers) {
InfluxDB influxDb = new InfluxDBImpl(properties.getUrl().toString(), properties.getUser(),
properties.getPassword(), determineBuilder(builder.getIfAvailable()));
customizers.orderedStream().forEach((customizer) -> customizer.customize(influxDb));
return influxDb;
}
private static OkHttpClient.Builder determineBuilder(InfluxDbOkHttpClientBuilderProvider builder) {
if (builder != null) {
return builder.get();
}
return new OkHttpClient.Builder();
}
}

41
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbCustomizer.java

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.influx;
import org.influxdb.InfluxDB;
/**
* Callback interface that can be implemented by beans wishing to further customize
* {@code InfluxDB} whilst retaining default auto-configuration.
*
* @author Eddú Meléndez
* @since 2.5.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new client</a> and its own
* Spring Boot integration.
*/
@FunctionalInterface
@Deprecated(since = "3.2.0", forRemoval = true)
public interface InfluxDbCustomizer {
/**
* Customize the {@link InfluxDB}.
* @param influxDb the InfluxDB instance to customize
*/
void customize(InfluxDB influxDb);
}

38
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbOkHttpClientBuilderProvider.java

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.influx;
import java.util.function.Supplier;
import okhttp3.OkHttpClient;
import org.influxdb.InfluxDB;
/**
* Provide the {@link okhttp3.OkHttpClient.Builder OkHttpClient.Builder} to use to
* customize the auto-configured {@link InfluxDB} instance.
*
* @author Stephane Nicoll
* @since 2.1.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new client</a> and its own
* Spring Boot integration.
*/
@FunctionalInterface
@Deprecated(since = "3.2.0", forRemoval = true)
public interface InfluxDbOkHttpClientBuilderProvider extends Supplier<OkHttpClient.Builder> {
}

81
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbProperties.java

@ -1,81 +0,0 @@ @@ -1,81 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.influx;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/**
* Configuration properties for InfluxDB.
*
* @author Sergey Kuptsov
* @author Stephane Nicoll
* @since 2.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of the
* <a href="https://github.com/influxdata/influxdb-client-java">new InfluxDB Java
* client</a> and its own Spring Boot integration.
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@ConfigurationProperties(prefix = "spring.influx")
public class InfluxDbProperties {
/**
* URL of the InfluxDB instance to which to connect.
*/
private String url;
/**
* Login user.
*/
private String user;
/**
* Login password.
*/
private String password;
@DeprecatedConfigurationProperty(reason = "the new InfluxDb Java client provides Spring Boot integration",
since = "3.2.0")
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
@DeprecatedConfigurationProperty(reason = "the new InfluxDb Java client provides Spring Boot integration",
since = "3.2.0")
public String getUser() {
return this.user;
}
public void setUser(String user) {
this.user = user;
}
@DeprecatedConfigurationProperty(reason = "the new InfluxDb Java client provides Spring Boot integration",
since = "3.2.0")
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}

20
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/package-info.java

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-configuration for InfluxDB.
*/
package org.springframework.boot.autoconfigure.influx;

17
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import javax.sql.DataSource; @@ -24,7 +24,6 @@ import javax.sql.DataSource;
import io.rsocket.transport.netty.server.TcpServerTransport;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
@ -43,7 +42,6 @@ import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurati @@ -43,7 +42,6 @@ import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurati
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@ -168,20 +166,13 @@ public class IntegrationAutoConfiguration { @@ -168,20 +166,13 @@ public class IntegrationAutoConfiguration {
* scheduling explicitly.
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(TaskSchedulerBuilder.class)
@ConditionalOnBean(ThreadPoolTaskSchedulerBuilder.class)
@ConditionalOnMissingBean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
@SuppressWarnings("removal")
protected static class IntegrationTaskSchedulerConfiguration {
@Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();
if (threadPoolTaskSchedulerBuilder != null) {
return threadPoolTaskSchedulerBuilder.build();
}
return taskSchedulerBuilder.build();
public ThreadPoolTaskScheduler taskScheduler(ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder) {
return threadPoolTaskSchedulerBuilder.build();
}
}

3
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java

@ -63,8 +63,7 @@ public class DataSourceTransactionManagerAutoConfiguration { @@ -63,8 +63,7 @@ public class DataSourceTransactionManagerAutoConfiguration {
DataSourceTransactionManager transactionManager(Environment environment, DataSource dataSource,
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
DataSourceTransactionManager transactionManager = createTransactionManager(environment, dataSource);
transactionManagerCustomizers
.ifAvailable((customizers) -> customizers.customize((TransactionManager) transactionManager));
transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(transactionManager));
return transactionManager;
}

59
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java

@ -176,21 +176,6 @@ public class KafkaProperties { @@ -176,21 +176,6 @@ public class KafkaProperties {
return properties;
}
/**
* Create an initial map of consumer properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary, and override the
* default {@code kafkaConsumerFactory} bean.
* @return the consumer properties initialized with the customizations defined on this
* instance
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #buildConsumerProperties(SslBundles)}}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public Map<String, Object> buildConsumerProperties() {
return buildConsumerProperties(null);
}
/**
* Create an initial map of consumer properties from the state of this instance.
* <p>
@ -206,21 +191,6 @@ public class KafkaProperties { @@ -206,21 +191,6 @@ public class KafkaProperties {
return properties;
}
/**
* Create an initial map of producer properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary, and override the
* default {@code kafkaProducerFactory} bean.
* @return the producer properties initialized with the customizations defined on this
* instance
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #buildProducerProperties(SslBundles)}}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public Map<String, Object> buildProducerProperties() {
return buildProducerProperties(null);
}
/**
* Create an initial map of producer properties from the state of this instance.
* <p>
@ -236,21 +206,6 @@ public class KafkaProperties { @@ -236,21 +206,6 @@ public class KafkaProperties {
return properties;
}
/**
* Create an initial map of admin properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary, and override the
* default {@code kafkaAdmin} bean.
* @return the admin properties initialized with the customizations defined on this
* instance
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #buildAdminProperties(SslBundles)}}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public Map<String, Object> buildAdminProperties() {
return buildAdminProperties(null);
}
/**
* Create an initial map of admin properties from the state of this instance.
* <p>
@ -266,20 +221,6 @@ public class KafkaProperties { @@ -266,20 +221,6 @@ public class KafkaProperties {
return properties;
}
/**
* Create an initial map of streams properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary.
* @return the streams properties initialized with the customizations defined on this
* instance
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #buildStreamsProperties(SslBundles)}}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public Map<String, Object> buildStreamsProperties() {
return buildStreamsProperties(null);
}
/**
* Create an initial map of streams properties from the state of this instance.
* <p>

3
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java

@ -95,8 +95,7 @@ public abstract class JpaBaseConfiguration { @@ -95,8 +95,7 @@ public abstract class JpaBaseConfiguration {
public PlatformTransactionManager transactionManager(
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManagerCustomizers
.ifAvailable((customizers) -> customizers.customize((TransactionManager) transactionManager));
transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(transactionManager));
return transactionManager;
}

1
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java

@ -36,7 +36,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -36,7 +36,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@AutoConfiguration
@EnableConfigurationProperties(TaskExecutionProperties.class)
@Import({ TaskExecutorConfigurations.ThreadPoolTaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.TaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.SimpleAsyncTaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.TaskExecutorConfiguration.class })
public class TaskExecutionAutoConfiguration {

51
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutorConfigurations.java

@ -24,8 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading; @@ -24,8 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder;
import org.springframework.boot.task.SimpleAsyncTaskExecutorCustomizer;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorCustomizer;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.context.annotation.Bean;
@ -49,7 +47,6 @@ class TaskExecutorConfigurations { @@ -49,7 +47,6 @@ class TaskExecutorConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class)
@SuppressWarnings("removal")
static class TaskExecutorConfiguration {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
@ -63,55 +60,19 @@ class TaskExecutorConfigurations { @@ -63,55 +60,19 @@ class TaskExecutorConfigurations {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder taskExecutorBuilder,
ObjectProvider<ThreadPoolTaskExecutorBuilder> threadPoolTaskExecutorBuilderProvider) {
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder = threadPoolTaskExecutorBuilderProvider
.getIfUnique();
if (threadPoolTaskExecutorBuilder != null) {
return threadPoolTaskExecutorBuilder.build();
}
return taskExecutorBuilder.build();
}
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
static class TaskExecutorBuilderConfiguration {
@Bean
@ConditionalOnMissingBean
@Deprecated(since = "3.2.0", forRemoval = true)
TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
TaskExecutorBuilder builder = new TaskExecutorBuilder();
builder = builder.queueCapacity(pool.getQueueCapacity());
builder = builder.corePoolSize(pool.getCoreSize());
builder = builder.maxPoolSize(pool.getMaxSize());
builder = builder.allowCoreThreadTimeOut(pool.isAllowCoreThreadTimeout());
builder = builder.keepAlive(pool.getKeepAlive());
TaskExecutionProperties.Shutdown shutdown = properties.getShutdown();
builder = builder.awaitTermination(shutdown.isAwaitTermination());
builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
builder = builder.customizers(taskExecutorCustomizers.orderedStream()::iterator);
builder = builder.taskDecorator(taskDecorator.getIfUnique());
return builder;
ThreadPoolTaskExecutor applicationTaskExecutor(ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder) {
return threadPoolTaskExecutorBuilder.build();
}
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
static class ThreadPoolTaskExecutorBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskExecutorBuilder.class, ThreadPoolTaskExecutorBuilder.class })
@ConditionalOnMissingBean(ThreadPoolTaskExecutorBuilder.class)
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<ThreadPoolTaskExecutorCustomizer> threadPoolTaskExecutorCustomizers,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
ThreadPoolTaskExecutorBuilder builder = new ThreadPoolTaskExecutorBuilder();
@ -127,15 +88,9 @@ class TaskExecutorConfigurations { @@ -127,15 +88,9 @@ class TaskExecutorConfigurations {
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
builder = builder.customizers(threadPoolTaskExecutorCustomizers.orderedStream()::iterator);
builder = builder.taskDecorator(taskDecorator.getIfUnique());
// Apply the deprecated TaskExecutorCustomizers, too
builder = builder.additionalCustomizers(taskExecutorCustomizers.orderedStream().map(this::adapt).toList());
return builder;
}
private ThreadPoolTaskExecutorCustomizer adapt(TaskExecutorCustomizer customizer) {
return customizer::customize;
}
}
@Configuration(proxyBeanMethods = false)

3
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,6 @@ import org.springframework.scheduling.config.TaskManagementConfigUtils; @@ -39,7 +39,6 @@ import org.springframework.scheduling.config.TaskManagementConfigUtils;
@AutoConfiguration(after = TaskExecutionAutoConfiguration.class)
@EnableConfigurationProperties(TaskSchedulingProperties.class)
@Import({ TaskSchedulingConfigurations.ThreadPoolTaskSchedulerBuilderConfiguration.class,
TaskSchedulingConfigurations.TaskSchedulerBuilderConfiguration.class,
TaskSchedulingConfigurations.SimpleAsyncTaskSchedulerBuilderConfiguration.class,
TaskSchedulingConfigurations.TaskSchedulerConfiguration.class })
public class TaskSchedulingAutoConfiguration {

47
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingConfigurations.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,8 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading; @@ -25,8 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerCustomizer;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.TaskSchedulerCustomizer;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerCustomizer;
import org.springframework.context.annotation.Bean;
@ -47,7 +45,6 @@ class TaskSchedulingConfigurations { @@ -47,7 +45,6 @@ class TaskSchedulingConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@ConditionalOnMissingBean({ TaskScheduler.class, ScheduledExecutorService.class })
@SuppressWarnings("removal")
static class TaskSchedulerConfiguration {
@Bean(name = "taskScheduler")
@ -58,47 +55,19 @@ class TaskSchedulingConfigurations { @@ -58,47 +55,19 @@ class TaskSchedulingConfigurations {
@Bean
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();
if (threadPoolTaskSchedulerBuilder != null) {
return threadPoolTaskSchedulerBuilder.build();
}
return taskSchedulerBuilder.build();
ThreadPoolTaskScheduler taskScheduler(ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder) {
return threadPoolTaskSchedulerBuilder.build();
}
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
static class TaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean
TaskSchedulerBuilder taskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
TaskSchedulerBuilder builder = new TaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
builder = builder.awaitTermination(shutdown.isAwaitTermination());
builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
builder = builder.customizers(taskSchedulerCustomizers);
return builder;
}
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
static class ThreadPoolTaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskSchedulerBuilder.class, ThreadPoolTaskSchedulerBuilder.class })
@ConditionalOnMissingBean(ThreadPoolTaskSchedulerBuilder.class)
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<ThreadPoolTaskSchedulerCustomizer> threadPoolTaskSchedulerCustomizers,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
ObjectProvider<ThreadPoolTaskSchedulerCustomizer> threadPoolTaskSchedulerCustomizers) {
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
ThreadPoolTaskSchedulerBuilder builder = new ThreadPoolTaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
@ -106,15 +75,9 @@ class TaskSchedulingConfigurations { @@ -106,15 +75,9 @@ class TaskSchedulingConfigurations {
builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
builder = builder.customizers(threadPoolTaskSchedulerCustomizers);
// Apply the deprecated TaskSchedulerCustomizers, too
builder = builder.additionalCustomizers(taskSchedulerCustomizers.orderedStream().map(this::adapt).toList());
return builder;
}
private ThreadPoolTaskSchedulerCustomizer adapt(TaskSchedulerCustomizer customizer) {
return customizer::customize;
}
}
@Configuration(proxyBeanMethods = false)

37
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.transaction;
import org.springframework.transaction.PlatformTransactionManager;
/**
* Callback interface that can be implemented by beans wishing to customize
* {@link PlatformTransactionManager PlatformTransactionManagers} whilst retaining default
* auto-configuration.
*
* @param <T> the transaction manager type
* @author Phillip Webb
* @since 1.5.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link TransactionManagerCustomizer}.
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@FunctionalInterface
public interface PlatformTransactionManagerCustomizer<T extends PlatformTransactionManager>
extends TransactionManagerCustomizer<T> {
}

29
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.Collections; @@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.List;
import org.springframework.boot.util.LambdaSafe;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
/**
@ -32,38 +31,14 @@ import org.springframework.transaction.TransactionManager; @@ -32,38 +31,14 @@ import org.springframework.transaction.TransactionManager;
* @author Andy Wilkinson
* @since 1.5.0
*/
public class TransactionManagerCustomizers {
public final class TransactionManagerCustomizers {
private final List<? extends TransactionManagerCustomizer<?>> customizers;
/**
* Creates a new {@code TransactionManagerCustomizers} instance containing the given
* {@code customizers}.
* @param customizers the customizers
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of {@link #of(Collection)}
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.2.0", forRemoval = true)
public TransactionManagerCustomizers(Collection<? extends PlatformTransactionManagerCustomizer<?>> customizers) {
this((customizers != null) ? new ArrayList<>(customizers)
: Collections.<TransactionManagerCustomizer<?>>emptyList());
}
private TransactionManagerCustomizers(List<? extends TransactionManagerCustomizer<?>> customizers) {
this.customizers = customizers;
}
/**
* Customize the given {@code platformTransactionManager}.
* @param platformTransactionManager the platform transaction manager to customize
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #customize(TransactionManager)}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public void customize(PlatformTransactionManager platformTransactionManager) {
customize((TransactionManager) platformTransactionManager);
}
/**
* Customize the given {@code transactionManager}.
* @param transactionManager the transaction manager to customize

6
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JndiJtaConfiguration.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean @@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.jta.JtaTransactionManager;
/**
@ -44,8 +43,7 @@ class JndiJtaConfiguration { @@ -44,8 +43,7 @@ class JndiJtaConfiguration {
JtaTransactionManager transactionManager(
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
transactionManagerCustomizers
.ifAvailable((customizers) -> customizers.customize((TransactionManager) jtaTransactionManager));
transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(jtaTransactionManager));
return jtaTransactionManager;
}

7
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java

@ -89,18 +89,11 @@ public class DispatcherServletAutoConfiguration { @@ -89,18 +89,11 @@ public class DispatcherServletAutoConfiguration {
DispatcherServlet dispatcherServlet = new DispatcherServlet();
dispatcherServlet.setDispatchOptionsRequest(webMvcProperties.isDispatchOptionsRequest());
dispatcherServlet.setDispatchTraceRequest(webMvcProperties.isDispatchTraceRequest());
configureThrowExceptionIfNoHandlerFound(webMvcProperties, dispatcherServlet);
dispatcherServlet.setPublishEvents(webMvcProperties.isPublishRequestHandledEvents());
dispatcherServlet.setEnableLoggingRequestDetails(webMvcProperties.isLogRequestDetails());
return dispatcherServlet;
}
@SuppressWarnings({ "deprecation", "removal" })
private void configureThrowExceptionIfNoHandlerFound(WebMvcProperties webMvcProperties,
DispatcherServlet dispatcherServlet) {
dispatcherServlet.setThrowExceptionIfNoHandlerFound(webMvcProperties.isThrowExceptionIfNoHandlerFound());
}
@Bean
@ConditionalOnBean(MultipartResolver.class)
@ConditionalOnMissingBean(name = DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME)

24
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.LinkedHashMap; @@ -21,7 +21,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.validation.DefaultMessageCodesResolver;
@ -62,14 +61,6 @@ public class WebMvcProperties { @@ -62,14 +61,6 @@ public class WebMvcProperties {
*/
private boolean publishRequestHandledEvents = true;
/**
* Whether a "NoHandlerFoundException" should be thrown if no Handler was found to
* process a request.
* @deprecated since 3.2.0 for removal in 3.4.0
*/
@Deprecated(since = "3.2.0", forRemoval = true)
private boolean throwExceptionIfNoHandlerFound = true;
/**
* Whether logging of (potentially sensitive) request details at DEBUG and TRACE level
* is allowed.
@ -124,19 +115,6 @@ public class WebMvcProperties { @@ -124,19 +115,6 @@ public class WebMvcProperties {
this.publishRequestHandledEvents = publishRequestHandledEvents;
}
@Deprecated(since = "3.2.0", forRemoval = true)
@DeprecatedConfigurationProperty(
reason = "DispatcherServlet property is deprecated for removal and should no longer need to be configured",
since = "3.2.0")
public boolean isThrowExceptionIfNoHandlerFound() {
return this.throwExceptionIfNoHandlerFound;
}
@Deprecated(since = "3.2.0", forRemoval = true)
public void setThrowExceptionIfNoHandlerFound(boolean throwExceptionIfNoHandlerFound) {
this.throwExceptionIfNoHandlerFound = throwExceptionIfNoHandlerFound;
}
public boolean isLogRequestDetails() {
return this.logRequestDetails;
}

28
spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@ -1586,6 +1586,27 @@ @@ -1586,6 +1586,27 @@
"level": "error"
}
},
{
"name": "spring.influx.password",
"deprecation": {
"level": "error",
"reason": "The new InfluxDb Java client provides Spring Boot integration."
}
},
{
"name": "spring.influx.url",
"deprecation": {
"level": "error",
"reason": "The new InfluxDb Java client provides Spring Boot integration."
}
},
{
"name": "spring.influx.user",
"deprecation": {
"level": "error",
"reason": "The new InfluxDb Java client provides Spring Boot integration."
}
},
{
"name": "spring.info.build.location",
"defaultValue": "classpath:META-INF/build-info.properties"
@ -2076,6 +2097,13 @@ @@ -2076,6 +2097,13 @@
"name": "spring.mvc.pathmatch.matching-strategy",
"defaultValue": "path-pattern-parser"
},
{
"name": "spring.mvc.throw-exception-if-no-handler-found",
"deprecation": {
"reason": "DispatcherServlet property is deprecated for removal and should no longer need to be configured.",
"level": "error"
}
},
{
"name": "spring.neo4j.security.trust-strategy",
"defaultValue": "trust-system-ca-signed-certificates"

1
spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@ -63,7 +63,6 @@ org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration @@ -63,7 +63,6 @@ org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration
org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration
org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration

114
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfigurationTests.java

@ -1,114 +0,0 @@ @@ -1,114 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.influx;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import org.influxdb.InfluxDB;
import org.junit.jupiter.api.Test;
import retrofit2.Retrofit;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link InfluxDbAutoConfiguration}.
*
* @author Sergey Kuptsov
* @author Stephane Nicoll
* @author Eddú Meléndez
* @author Moritz Halbritter
* @author Andy Wilkinson
* @author Phillip Webb
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.2.0", forRemoval = true)
class InfluxDbAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(InfluxDbAutoConfiguration.class));
@Test
void influxDbRequiresUrl() {
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(InfluxDB.class));
}
@Test
void influxDbCanBeCustomized() {
this.contextRunner
.withPropertyValues("spring.influx.url=http://localhost", "spring.influx.user=user",
"spring.influx.password=password")
.run((context) -> assertThat(context).hasSingleBean(InfluxDB.class));
}
@Test
void influxDbCanBeCreatedWithoutCredentials() {
this.contextRunner.withPropertyValues("spring.influx.url=http://localhost").run((context) -> {
assertThat(context).hasSingleBean(InfluxDB.class);
int readTimeout = getReadTimeoutProperty(context);
assertThat(readTimeout).isEqualTo(10_000);
});
}
@Test
void influxDbWithOkHttpClientBuilderProvider() {
this.contextRunner.withUserConfiguration(CustomOkHttpClientBuilderProviderConfig.class)
.withPropertyValues("spring.influx.url=http://localhost")
.run((context) -> {
assertThat(context).hasSingleBean(InfluxDB.class);
int readTimeout = getReadTimeoutProperty(context);
assertThat(readTimeout).isEqualTo(40_000);
});
}
@Test
void influxDbWithCustomizer() {
this.contextRunner.withBean(InfluxDbCustomizer.class, () -> (influxDb) -> influxDb.setDatabase("test"))
.withPropertyValues("spring.influx.url=http://localhost")
.run((context) -> {
assertThat(context).hasSingleBean(InfluxDB.class);
InfluxDB influxDb = context.getBean(InfluxDB.class);
assertThat(influxDb).hasFieldOrPropertyWithValue("database", "test");
});
}
private int getReadTimeoutProperty(AssertableApplicationContext context) {
InfluxDB influxDb = context.getBean(InfluxDB.class);
Retrofit retrofit = (Retrofit) ReflectionTestUtils.getField(influxDb, "retrofit");
OkHttpClient callFactory = (OkHttpClient) retrofit.callFactory();
return callFactory.readTimeoutMillis();
}
@Configuration(proxyBeanMethods = false)
static class CustomOkHttpClientBuilderProviderConfig {
@Bean
@SuppressWarnings("removal")
InfluxDbOkHttpClientBuilderProvider influxDbOkHttpClientBuilderProvider() {
return () -> new OkHttpClient.Builder().readTimeout(40, TimeUnit.SECONDS);
}
}
}

122
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java

@ -32,8 +32,6 @@ import org.junit.jupiter.api.extension.ExtendWith; @@ -32,8 +32,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorCustomizer;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -51,7 +49,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @@ -51,7 +49,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
/**
@ -63,7 +60,6 @@ import static org.mockito.Mockito.mock; @@ -63,7 +60,6 @@ import static org.mockito.Mockito.mock;
* @author Yanming Zhou
*/
@ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings("removal")
class TaskExecutionAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@ -72,43 +68,12 @@ class TaskExecutionAutoConfigurationTests { @@ -72,43 +68,12 @@ class TaskExecutionAutoConfigurationTests {
@Test
void shouldSupplyBeans() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskExecutorBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskExecutor.class);
assertThat(context).hasSingleBean(SimpleAsyncTaskExecutorBuilder.class);
});
}
@Test
void shouldNotSupplyThreadPoolTaskExecutorBuilderIfCustomTaskExecutorBuilderIsPresent() {
this.contextRunner.withBean(TaskExecutorBuilder.class, TaskExecutorBuilder::new).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
assertThat(context).doesNotHaveBean(ThreadPoolTaskExecutorBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskExecutor.class);
});
}
@Test
void taskExecutorBuilderShouldApplyCustomSettings() {
this.contextRunner
.withPropertyValues("spring.task.execution.pool.queue-capacity=10",
"spring.task.execution.pool.core-size=2", "spring.task.execution.pool.max-size=4",
"spring.task.execution.pool.allow-core-thread-timeout=true",
"spring.task.execution.pool.keep-alive=5s", "spring.task.execution.shutdown.await-termination=true",
"spring.task.execution.shutdown.await-termination-period=30s",
"spring.task.execution.thread-name-prefix=mytest-")
.run(assertTaskExecutor((taskExecutor) -> {
assertThat(taskExecutor).hasFieldOrPropertyWithValue("queueCapacity", 10);
assertThat(taskExecutor.getCorePoolSize()).isEqualTo(2);
assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(4);
assertThat(taskExecutor).hasFieldOrPropertyWithValue("allowCoreThreadTimeOut", true);
assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(5);
assertThat(taskExecutor).hasFieldOrPropertyWithValue("waitForTasksToCompleteOnShutdown", true);
assertThat(taskExecutor).hasFieldOrPropertyWithValue("awaitTerminationMillis", 30000L);
assertThat(taskExecutor.getThreadNamePrefix()).isEqualTo("mytest-");
}));
}
@Test
void simpleAsyncTaskExecutorBuilderShouldReadProperties() {
this.contextRunner
@ -145,15 +110,6 @@ class TaskExecutionAutoConfigurationTests { @@ -145,15 +110,6 @@ class TaskExecutionAutoConfigurationTests {
}));
}
@Test
void taskExecutorBuilderWhenHasCustomBuilderShouldUseCustomBuilder() {
this.contextRunner.withUserConfiguration(CustomTaskExecutorBuilderConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
assertThat(context.getBean(TaskExecutorBuilder.class))
.isSameAs(context.getBean(CustomTaskExecutorBuilderConfig.class).taskExecutorBuilder);
});
}
@Test
void threadPoolTaskExecutorBuilderWhenHasCustomBuilderShouldUseCustomBuilder() {
this.contextRunner.withUserConfiguration(CustomThreadPoolTaskExecutorBuilderConfig.class).run((context) -> {
@ -163,15 +119,6 @@ class TaskExecutionAutoConfigurationTests { @@ -163,15 +119,6 @@ class TaskExecutionAutoConfigurationTests {
});
}
@Test
void taskExecutorBuilderShouldUseTaskDecorator() {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build();
assertThat(executor).extracting("taskDecorator").isSameAs(context.getBean(TaskDecorator.class));
});
}
@Test
void threadPoolTaskExecutorBuilderShouldUseTaskDecorator() {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
@ -274,24 +221,6 @@ class TaskExecutionAutoConfigurationTests { @@ -274,24 +221,6 @@ class TaskExecutionAutoConfigurationTests {
});
}
@Test
void taskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = context.getBean(TaskExecutorBuilder.class).build();
then(customizer).should().customize(executor);
});
}
@Test
void threadPoolTaskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = context.getBean(ThreadPoolTaskExecutorBuilder.class).build();
then(customizer).should().customize(executor);
});
}
@Test
void enableAsyncUsesAutoConfiguredOneByDefault() {
this.contextRunner.withPropertyValues("spring.task.execution.thread-name-prefix=task-test-")
@ -316,34 +245,6 @@ class TaskExecutionAutoConfigurationTests { @@ -316,34 +245,6 @@ class TaskExecutionAutoConfigurationTests {
});
}
@Test
void customTaskExecutorBuilderOverridesThreadPoolTaskExecutorBuilder() {
this.contextRunner.withUserConfiguration(CustomTaskExecutorBuilderConfig.class).run((context) -> {
ThreadPoolTaskExecutor bean = context.getBean(ThreadPoolTaskExecutor.class);
assertThat(bean.getThreadNamePrefix()).isEqualTo("CustomTaskExecutorBuilderConfig-");
});
}
@Test
void threadPoolTaskExecutorBuilderAppliesTaskExecutorCustomizer() {
this.contextRunner
.withBean(TaskExecutorCustomizer.class,
() -> (taskExecutor) -> taskExecutor.setThreadNamePrefix("custom-prefix-"))
.run((context) -> {
ThreadPoolTaskExecutor bean = context.getBean(ThreadPoolTaskExecutor.class);
assertThat(bean.getThreadNamePrefix()).isEqualTo("custom-prefix-");
});
}
private ContextConsumer<AssertableApplicationContext> assertTaskExecutor(
Consumer<ThreadPoolTaskExecutor> taskExecutor) {
return (context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
TaskExecutorBuilder builder = context.getBean(TaskExecutorBuilder.class);
taskExecutor.accept(builder.build());
};
}
private ContextConsumer<AssertableApplicationContext> assertThreadPoolTaskExecutor(
Consumer<ThreadPoolTaskExecutor> taskExecutor) {
return (context) -> {
@ -376,19 +277,6 @@ class TaskExecutionAutoConfigurationTests { @@ -376,19 +277,6 @@ class TaskExecutionAutoConfigurationTests {
return thread.getName();
}
@Configuration(proxyBeanMethods = false)
static class CustomTaskExecutorBuilderConfig {
private final TaskExecutorBuilder taskExecutorBuilder = new TaskExecutorBuilder()
.threadNamePrefix("CustomTaskExecutorBuilderConfig-");
@Bean
TaskExecutorBuilder customTaskExecutorBuilder() {
return this.taskExecutorBuilder;
}
}
@Configuration(proxyBeanMethods = false)
static class CustomThreadPoolTaskExecutorBuilderConfig {
@ -401,16 +289,6 @@ class TaskExecutionAutoConfigurationTests { @@ -401,16 +289,6 @@ class TaskExecutionAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class TaskExecutorCustomizerConfig {
@Bean
TaskExecutorCustomizer mockTaskExecutorCustomizer() {
return mock(TaskExecutorCustomizer.class);
}
}
@Configuration(proxyBeanMethods = false)
static class TaskDecoratorConfig {

40
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,8 +36,6 @@ import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor; @@ -36,8 +36,6 @@ import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerCustomizer;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.TaskSchedulerCustomizer;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerCustomizer;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -59,7 +57,6 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -59,7 +57,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
* @author Moritz Halbritter
*/
@SuppressWarnings("removal")
class TaskSchedulingAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@ -80,23 +77,11 @@ class TaskSchedulingAutoConfigurationTests { @@ -80,23 +77,11 @@ class TaskSchedulingAutoConfigurationTests {
@Test
void shouldSupplyBeans() {
this.contextRunner.withUserConfiguration(SchedulingConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(TaskSchedulerBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskSchedulerBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskScheduler.class);
});
}
@Test
void shouldNotSupplyThreadPoolTaskSchedulerBuilderIfCustomTaskSchedulerBuilderIsPresent() {
this.contextRunner.withUserConfiguration(SchedulingConfiguration.class)
.withBean(TaskSchedulerBuilder.class, TaskSchedulerBuilder::new)
.run((context) -> {
assertThat(context).hasSingleBean(TaskSchedulerBuilder.class);
assertThat(context).doesNotHaveBean(ThreadPoolTaskSchedulerBuilder.class);
assertThat(context).hasSingleBean(ThreadPoolTaskScheduler.class);
});
}
@Test
void enableSchedulingWithNoTaskExecutorAutoConfiguresOne() {
this.contextRunner
@ -155,7 +140,6 @@ class TaskSchedulingAutoConfigurationTests { @@ -155,7 +140,6 @@ class TaskSchedulingAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void simpleAsyncTaskSchedulerBuilderShouldApplyCustomizers() {
SimpleAsyncTaskSchedulerCustomizer customizer = (scheduler) -> {
};
@ -170,18 +154,6 @@ class TaskSchedulingAutoConfigurationTests { @@ -170,18 +154,6 @@ class TaskSchedulingAutoConfigurationTests {
});
}
@Test
void enableSchedulingWithNoTaskExecutorAppliesTaskSchedulerCustomizers() {
this.contextRunner.withPropertyValues("spring.task.scheduling.thread-name-prefix=scheduling-test-")
.withUserConfiguration(SchedulingConfiguration.class, TaskSchedulerCustomizerConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(TaskExecutor.class);
TestBean bean = context.getBean(TestBean.class);
assertThat(bean.latch.await(30, TimeUnit.SECONDS)).isTrue();
assertThat(bean.threadNames).allMatch((name) -> name.contains("customized-scheduler-"));
});
}
@Test
void enableSchedulingWithNoTaskExecutorAppliesCustomizers() {
this.contextRunner.withPropertyValues("spring.task.scheduling.thread-name-prefix=scheduling-test-")
@ -262,16 +234,6 @@ class TaskSchedulingAutoConfigurationTests { @@ -262,16 +234,6 @@ class TaskSchedulingAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class TaskSchedulerCustomizerConfiguration {
@Bean
TaskSchedulerCustomizer testTaskSchedulerCustomizer() {
return ((taskScheduler) -> taskScheduler.setThreadNamePrefix("customized-scheduler-"));
}
}
@Configuration(proxyBeanMethods = false)
static class ThreadPoolTaskSchedulerCustomizerConfiguration {

6
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizersTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,8 +46,8 @@ class TransactionManagerCustomizersTests { @@ -46,8 +46,8 @@ class TransactionManagerCustomizersTests {
list.add(new TestCustomizer<>());
list.add(new TestJtaCustomizer());
TransactionManagerCustomizers customizers = TransactionManagerCustomizers.of(list);
customizers.customize((TransactionManager) mock(PlatformTransactionManager.class));
customizers.customize((TransactionManager) mock(JtaTransactionManager.class));
customizers.customize(mock(PlatformTransactionManager.class));
customizers.customize(mock(JtaTransactionManager.class));
assertThat(list.get(0).getCount()).isEqualTo(2);
assertThat(list.get(1).getCount()).isOne();
}

13
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java

@ -162,12 +162,10 @@ class DispatcherServletAutoConfigurationTests { @@ -162,12 +162,10 @@ class DispatcherServletAutoConfigurationTests {
@Test
void dispatcherServletCustomConfig() {
this.contextRunner
.withPropertyValues("spring.mvc.throw-exception-if-no-handler-found:false",
"spring.mvc.dispatch-options-request:false", "spring.mvc.dispatch-trace-request:true",
.withPropertyValues("spring.mvc.dispatch-options-request:false", "spring.mvc.dispatch-trace-request:true",
"spring.mvc.publish-request-handled-events:false", "spring.mvc.servlet.load-on-startup=5")
.run((context) -> {
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(false);
assertThat(dispatcherServlet).extracting("dispatchOptionsRequest").isEqualTo(false);
assertThat(dispatcherServlet).extracting("dispatchTraceRequest").isEqualTo(true);
assertThat(dispatcherServlet).extracting("publishEvents").isEqualTo(false);
@ -176,15 +174,6 @@ class DispatcherServletAutoConfigurationTests { @@ -176,15 +174,6 @@ class DispatcherServletAutoConfigurationTests {
});
}
@Test
@Deprecated(since = "3.2.0", forRemoval = true)
void dispatcherServletThrowExceptionIfNoHandlerFoundCustomConfig() {
this.contextRunner.withPropertyValues("spring.mvc.throw-exception-if-no-handler-found:false").run((context) -> {
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(false);
});
}
@Configuration(proxyBeanMethods = false)
static class MultipartConfiguration {

6
spring-boot-project/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc

@ -609,7 +609,7 @@ @@ -609,7 +609,7 @@
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.arguments[maven-plugin#integration-tests.start-goal.parameter-details.arguments]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.classes-directory[maven-plugin#integration-tests.start-goal.parameter-details.classes-directory]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.commandline-arguments[maven-plugin#integration-tests.start-goal.parameter-details.commandline-arguments]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.directories[maven-plugin#integration-tests.start-goal.parameter-details.directories]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.additional-classpath-elements[maven-plugin#integration-tests.start-goal.parameter-details.directories]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.environment-variables[maven-plugin#integration-tests.start-goal.parameter-details.environment-variables]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.exclude-group-ids[maven-plugin#integration-tests.start-goal.parameter-details.exclude-group-ids]
* xref:maven-plugin:integration-tests.adoc#integration-tests.start-goal.parameter-details.excludes[maven-plugin#integration-tests.start-goal.parameter-details.excludes]
@ -685,7 +685,7 @@ @@ -685,7 +685,7 @@
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.arguments[maven-plugin#run.run-goal.parameter-details.arguments]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.classes-directory[maven-plugin#run.run-goal.parameter-details.classes-directory]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.commandline-arguments[maven-plugin#run.run-goal.parameter-details.commandline-arguments]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.directories[maven-plugin#run.run-goal.parameter-details.directories]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.additional-classpath-elements[maven-plugin#run.run-goal.parameter-details.directories]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.environment-variables[maven-plugin#run.run-goal.parameter-details.environment-variables]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.exclude-group-ids[maven-plugin#run.run-goal.parameter-details.exclude-group-ids]
* xref:maven-plugin:run.adoc#run.run-goal.parameter-details.excludes[maven-plugin#run.run-goal.parameter-details.excludes]
@ -709,7 +709,7 @@ @@ -709,7 +709,7 @@
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.arguments[maven-plugin#run.test-run-goal.parameter-details.arguments]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.classes-directory[maven-plugin#run.test-run-goal.parameter-details.classes-directory]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.commandline-arguments[maven-plugin#run.test-run-goal.parameter-details.commandline-arguments]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.directories[maven-plugin#run.test-run-goal.parameter-details.directories]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.additional-classpath-elements[maven-plugin#run.test-run-goal.parameter-details.directories]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.environment-variables[maven-plugin#run.test-run-goal.parameter-details.environment-variables]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.exclude-group-ids[maven-plugin#run.test-run-goal.parameter-details.exclude-group-ids]
* xref:maven-plugin:run.adoc#run.test-run-goal.parameter-details.excludes[maven-plugin#run.test-run-goal.parameter-details.excludes]

4
spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/endpoints.adoc

@ -616,10 +616,6 @@ with the `key` listed in the following table: @@ -616,10 +616,6 @@ with the `key` listed in the following table:
| xref:api:java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicator.html[`HazelcastHealthIndicator`]
| Checks that a Hazelcast server is up.
| `influxdb`
| xref:api:java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicator.html[`InfluxDbHealthIndicator`]
| Checks that an InfluxDB server is up.
| `jms`
| xref:api:java/org/springframework/boot/actuate/jms/JmsHealthIndicator.html[`JmsHealthIndicator`]
| Checks that a JMS broker is up.

7
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcConfiguration.java

@ -83,13 +83,6 @@ class MockMvcConfiguration { @@ -83,13 +83,6 @@ class MockMvcConfiguration {
public void customize(DispatcherServlet dispatcherServlet) {
dispatcherServlet.setDispatchOptionsRequest(this.webMvcProperties.isDispatchOptionsRequest());
dispatcherServlet.setDispatchTraceRequest(this.webMvcProperties.isDispatchTraceRequest());
configureThrowExceptionIfNoHandlerFound(dispatcherServlet);
}
@SuppressWarnings({ "deprecation", "removal" })
private void configureThrowExceptionIfNoHandlerFound(DispatcherServlet dispatcherServlet) {
dispatcherServlet
.setThrowExceptionIfNoHandlerFound(this.webMvcProperties.isThrowExceptionIfNoHandlerFound());
}
}

5
spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java

@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testcontainers.lifecycle.BeforeTestcontainerUsedEvent;
import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleApplicationContextInitializer;
import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable;
import org.springframework.boot.testsupport.container.RedisContainer;
@ -50,7 +51,6 @@ class TestcontainersPropertySourceAutoConfigurationTests { @@ -50,7 +51,6 @@ class TestcontainersPropertySourceAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(TestcontainersPropertySourceAutoConfiguration.class));
@Test
@SuppressWarnings("removal")
void containerBeanMethodContributesProperties() {
List<ApplicationEvent> events = new ArrayList<>();
this.contextRunner.withUserConfiguration(ContainerAndPropertiesConfiguration.class)
@ -59,8 +59,7 @@ class TestcontainersPropertySourceAutoConfigurationTests { @@ -59,8 +59,7 @@ class TestcontainersPropertySourceAutoConfigurationTests {
TestBean testBean = context.getBean(TestBean.class);
RedisContainer redisContainer = context.getBean(RedisContainer.class);
assertThat(testBean.getUsingPort()).isEqualTo(redisContainer.getFirstMappedPort());
assertThat(events.stream().filter(BeforeTestcontainersPropertySuppliedEvent.class::isInstance))
.hasSize(1);
assertThat(events.stream().filter(BeforeTestcontainerUsedEvent.class::isInstance)).hasSize(1);
});
}

50
spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/BeforeTestcontainersPropertySuppliedEvent.java

@ -1,50 +0,0 @@ @@ -1,50 +0,0 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.testcontainers.properties;
import java.util.function.Supplier;
import org.springframework.boot.testcontainers.lifecycle.BeforeTestcontainerUsedEvent;
/**
* Event published just before the {@link Supplier value supplier} of a
* {@link TestcontainersPropertySource} property is called.
*
* @author Phillip Webb
* @since 3.2.2
* @deprecated since 3.2.6 for removal in 3.4.0 in favor of
* {@link BeforeTestcontainerUsedEvent}
*/
@Deprecated(since = "3.2.6", forRemoval = true)
public class BeforeTestcontainersPropertySuppliedEvent extends BeforeTestcontainerUsedEvent {
private final String propertyName;
BeforeTestcontainersPropertySuppliedEvent(TestcontainersPropertySource source, String propertyName) {
super(source);
this.propertyName = propertyName;
}
/**
* Return the name of the property about to be supplied.
* @return the propertyName the property name
*/
public String getPropertyName() {
return this.propertyName;
}
}

4
spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java

@ -30,6 +30,7 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; @@ -30,6 +30,7 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.testcontainers.lifecycle.BeforeTestcontainerUsedEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ConfigurableApplicationContext;
@ -80,9 +81,8 @@ public class TestcontainersPropertySource extends MapPropertySource { @@ -80,9 +81,8 @@ public class TestcontainersPropertySource extends MapPropertySource {
return (valueSupplier != null) ? getProperty(name, valueSupplier) : null;
}
@SuppressWarnings({ "removal", "deprecation" })
private Object getProperty(String name, Object valueSupplier) {
BeforeTestcontainersPropertySuppliedEvent event = new BeforeTestcontainersPropertySuppliedEvent(this, name);
BeforeTestcontainerUsedEvent event = new BeforeTestcontainerUsedEvent(this);
this.eventPublishers.forEach((eventPublisher) -> eventPublisher.publishEvent(event));
return SupplierUtils.resolve(valueSupplier);
}

4
spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceTests.java

@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test; @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.testcontainers.lifecycle.BeforeTestcontainerUsedEvent;
import org.springframework.boot.testcontainers.properties.TestcontainersPropertySource.EventPublisherRegistrar;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.support.GenericApplicationContext;
@ -134,7 +135,6 @@ class TestcontainersPropertySourceTests { @@ -134,7 +135,6 @@ class TestcontainersPropertySourceTests {
}
@Test
@SuppressWarnings("removal")
void getPropertyPublishesEvent() {
try (GenericApplicationContext applicationContext = new GenericApplicationContext()) {
List<ApplicationEvent> events = new ArrayList<>();
@ -146,7 +146,7 @@ class TestcontainersPropertySourceTests { @@ -146,7 +146,7 @@ class TestcontainersPropertySourceTests {
assertThat(applicationContext.getEnvironment().containsProperty("test")).isTrue();
assertThat(events.isEmpty());
assertThat(applicationContext.getEnvironment().getProperty("test")).isEqualTo("spring");
assertThat(events.stream().filter(BeforeTestcontainersPropertySuppliedEvent.class::isInstance)).hasSize(1);
assertThat(events.stream().filter(BeforeTestcontainerUsedEvent.class::isInstance)).hasSize(1);
}
}

8
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java

@ -108,14 +108,6 @@ class RunIntegrationTests { @@ -108,14 +108,6 @@ class RunIntegrationTests {
.execute((project) -> assertThat(buildLog(project)).containsPattern("I haz been run from.*src.main.java"));
}
@TestTemplate
@Deprecated(since = "3.2.0", forRemoval = true)
void whenDirectoriesAreConfiguredTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
mavenBuild.project("run-directories")
.goals("spring-boot:run")
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
}
@TestTemplate
void whenAdditionalClasspathDirectoryIsConfiguredItsResourcesAreAvailableToTheApplication(MavenBuild mavenBuild) {
mavenBuild.project("run-additional-classpath-directory")

27
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/pom.xml

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.boot.maven.it</groupId>
<artifactId>run-directories</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>@java.version@</maven.compiler.source>
<maven.compiler.target>@java.version@</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<directories>
<directory>src/main/additional-elements/</directory>
</directories>
</configuration>
</plugin>
</plugins>
</build>
</project>

1
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/additional-elements/another/two.txt

@ -1 +0,0 @@ @@ -1 +0,0 @@
2

1
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/additional-elements/one.txt

@ -1 +0,0 @@ @@ -1 +0,0 @@
1

45
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-directories/src/main/java/org/test/SampleApplication.java

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.test;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
public class SampleApplication {
public static void main(String[] args) {
if (!readContent("one.txt").contains("1")) {
throw new IllegalArgumentException("Invalid content for one.txt");
}
if (!readContent("another/two.txt").contains("2")) {
throw new IllegalArgumentException("Invalid content for another/two.txt");
}
System.out.println("I haz been run");
}
private static String readContent(String location) {
InputStream in = SampleApplication.class.getClassLoader().getResourceAsStream(location);
if (in == null) {
throw new IllegalArgumentException("Not found: '" + location + "'");
}
try (Scanner scanner = new Scanner(in, StandardCharsets.UTF_8)) {
return scanner.useDelimiter("\\A").next();
}
}
}

21
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java

@ -42,8 +42,6 @@ import org.apache.maven.project.MavenProject; @@ -42,8 +42,6 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.ToolchainManager;
import org.springframework.boot.loader.tools.FileUtils;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
@ -171,17 +169,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { @@ -171,17 +169,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
@Parameter(property = "spring-boot.run.main-class")
private String mainClass;
/**
* Additional directories containing classes or resources that should be added to the
* classpath.
* @since 1.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* 'additionalClasspathElements'
*/
@Parameter(property = "spring-boot.run.directories")
@Deprecated(since = "3.2.0", forRemoval = true)
private String[] directories;
/**
* Additional classpath elements that should be added to the classpath. An element can
* be a directory with classes and resources or a jar file.
@ -403,12 +390,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { @@ -403,12 +390,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
private void addAdditionalClasspathLocations(List<URL> urls) throws MalformedURLException {
Assert.state(ObjectUtils.isEmpty(this.directories) || ObjectUtils.isEmpty(this.additionalClasspathElements),
"Either additionalClasspathElements or directories (deprecated) should be set, not both");
String[] elements = !ObjectUtils.isEmpty(this.additionalClasspathElements) ? this.additionalClasspathElements
: this.directories;
if (elements != null) {
for (String element : elements) {
if (this.additionalClasspathElements != null) {
for (String element : this.additionalClasspathElements) {
urls.add(new File(element).toURI().toURL());
}
}

123
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationContextInitializer.java

@ -1,123 +0,0 @@ @@ -1,123 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* {@link ApplicationContextInitializer} that delegates to other initializers that are
* specified under a {@literal context.initializer.classes} environment property.
*
* @author Dave Syer
* @author Phillip Webb
* @since 1.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 as property based initialization is no
* longer recommended
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public class DelegatingApplicationContextInitializer
implements ApplicationContextInitializer<ConfigurableApplicationContext>, Ordered {
// NOTE: Similar to org.springframework.web.context.ContextLoader
private static final String PROPERTY_NAME = "context.initializer.classes";
private int order = 0;
@Override
public void initialize(ConfigurableApplicationContext context) {
ConfigurableEnvironment environment = context.getEnvironment();
List<Class<?>> initializerClasses = getInitializerClasses(environment);
if (!initializerClasses.isEmpty()) {
applyInitializerClasses(context, initializerClasses);
}
}
private List<Class<?>> getInitializerClasses(ConfigurableEnvironment env) {
String classNames = env.getProperty(PROPERTY_NAME);
List<Class<?>> classes = new ArrayList<>();
if (StringUtils.hasLength(classNames)) {
for (String className : StringUtils.tokenizeToStringArray(classNames, ",")) {
classes.add(getInitializerClass(className));
}
}
return classes;
}
private Class<?> getInitializerClass(String className) throws LinkageError {
try {
Class<?> initializerClass = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
Assert.isAssignable(ApplicationContextInitializer.class, initializerClass);
return initializerClass;
}
catch (ClassNotFoundException ex) {
throw new ApplicationContextException("Failed to load context initializer class [" + className + "]", ex);
}
}
private void applyInitializerClasses(ConfigurableApplicationContext context, List<Class<?>> initializerClasses) {
Class<?> contextClass = context.getClass();
List<ApplicationContextInitializer<?>> initializers = new ArrayList<>();
for (Class<?> initializerClass : initializerClasses) {
initializers.add(instantiateInitializer(contextClass, initializerClass));
}
applyInitializers(context, initializers);
}
private ApplicationContextInitializer<?> instantiateInitializer(Class<?> contextClass, Class<?> initializerClass) {
Class<?> requireContextClass = GenericTypeResolver.resolveTypeArgument(initializerClass,
ApplicationContextInitializer.class);
Assert.isAssignable(requireContextClass, contextClass,
() -> String.format(
"Could not add context initializer [%s] as its generic parameter [%s] is not assignable "
+ "from the type of application context used by this context loader [%s]: ",
initializerClass.getName(), requireContextClass.getName(), contextClass.getName()));
return (ApplicationContextInitializer<?>) BeanUtils.instantiateClass(initializerClass);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void applyInitializers(ConfigurableApplicationContext context,
List<ApplicationContextInitializer<?>> initializers) {
initializers.sort(new AnnotationAwareOrderComparator());
for (ApplicationContextInitializer initializer : initializers) {
initializer.initialize(context);
}
}
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
}

108
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/DelegatingApplicationListener.java

@ -1,108 +0,0 @@ @@ -1,108 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* {@link ApplicationListener} that delegates to other listeners that are specified under
* a {@literal context.listener.classes} environment property.
*
* @author Dave Syer
* @author Phillip Webb
* @since 1.0.0
* @deprecated since 3.2.0 for removal in 3.4.0 as property based initialization is no
* longer recommended
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public class DelegatingApplicationListener implements ApplicationListener<ApplicationEvent>, Ordered {
// NOTE: Similar to org.springframework.web.context.ContextLoader
private static final String PROPERTY_NAME = "context.listener.classes";
private int order = 0;
private SimpleApplicationEventMulticaster multicaster;
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationEnvironmentPreparedEvent preparedEvent) {
List<ApplicationListener<ApplicationEvent>> delegates = getListeners(preparedEvent.getEnvironment());
if (delegates.isEmpty()) {
return;
}
this.multicaster = new SimpleApplicationEventMulticaster();
for (ApplicationListener<ApplicationEvent> listener : delegates) {
this.multicaster.addApplicationListener(listener);
}
}
if (this.multicaster != null) {
this.multicaster.multicastEvent(event);
}
}
@SuppressWarnings("unchecked")
private List<ApplicationListener<ApplicationEvent>> getListeners(ConfigurableEnvironment environment) {
if (environment == null) {
return Collections.emptyList();
}
String classNames = environment.getProperty(PROPERTY_NAME);
List<ApplicationListener<ApplicationEvent>> listeners = new ArrayList<>();
if (StringUtils.hasLength(classNames)) {
for (String className : StringUtils.commaDelimitedListToSet(classNames)) {
try {
Class<?> clazz = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
Assert.isAssignable(ApplicationListener.class, clazz,
() -> "class [" + className + "] must implement ApplicationListener");
listeners.add((ApplicationListener<ApplicationEvent>) BeanUtils.instantiateClass(clazz));
}
catch (Exception ex) {
throw new ApplicationContextException("Failed to load context listener class [" + className + "]",
ex);
}
}
}
AnnotationAwareOrderComparator.sort(listeners);
return listeners;
}
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
}

140
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java

@ -44,117 +44,6 @@ import org.springframework.util.StringUtils; @@ -44,117 +44,6 @@ import org.springframework.util.StringUtils;
*/
public class LoggingSystemProperties {
/**
* The name of the System property that contains the process ID.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#PID}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String PID_KEY = LoggingSystemProperty.PID.getEnvironmentVariableName();
/**
* The name of the System property that contains the exception conversion word.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#EXCEPTION_CONVERSION_WORD}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String EXCEPTION_CONVERSION_WORD = LoggingSystemProperty.EXCEPTION_CONVERSION_WORD
.getEnvironmentVariableName();
/**
* The name of the System property that contains the log file.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#LOG_FILE}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String LOG_FILE = LoggingSystemProperty.LOG_FILE.getEnvironmentVariableName();
/**
* The name of the System property that contains the log path.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#LOG_PATH}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String LOG_PATH = LoggingSystemProperty.LOG_PATH.getEnvironmentVariableName();
/**
* The name of the System property that contains the console log pattern.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#CONSOLE_PATTERN}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String CONSOLE_LOG_PATTERN = LoggingSystemProperty.CONSOLE_PATTERN.getEnvironmentVariableName();
/**
* The name of the System property that contains the console log charset.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#CONSOLE_CHARSET}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String CONSOLE_LOG_CHARSET = LoggingSystemProperty.CONSOLE_CHARSET.getEnvironmentVariableName();
/**
* The log level threshold for console log.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#CONSOLE_THRESHOLD}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String CONSOLE_LOG_THRESHOLD = LoggingSystemProperty.CONSOLE_THRESHOLD
.getEnvironmentVariableName();
/**
* The name of the System property that contains the file log pattern.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#FILE_PATTERN}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String FILE_LOG_PATTERN = LoggingSystemProperty.FILE_PATTERN.getEnvironmentVariableName();
/**
* The name of the System property that contains the file log charset.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#FILE_CHARSET}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String FILE_LOG_CHARSET = LoggingSystemProperty.FILE_CHARSET.getEnvironmentVariableName();
/**
* The log level threshold for file log.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#FILE_THRESHOLD}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String FILE_LOG_THRESHOLD = LoggingSystemProperty.FILE_THRESHOLD.getEnvironmentVariableName();
/**
* The name of the System property that contains the log level pattern.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#LEVEL_PATTERN}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String LOG_LEVEL_PATTERN = LoggingSystemProperty.LEVEL_PATTERN.getEnvironmentVariableName();
/**
* The name of the System property that contains the log date-format pattern.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link LoggingSystemProperty#getEnvironmentVariableName()} on
* {@link LoggingSystemProperty#DATEFORMAT_PATTERN}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String LOG_DATEFORMAT_PATTERN = LoggingSystemProperty.DATEFORMAT_PATTERN
.getEnvironmentVariableName();
private static final BiConsumer<String, String> systemPropertySetter = (name, value) -> {
if (System.getProperty(name) == null && value != null) {
System.setProperty(name, value);
@ -300,35 +189,6 @@ public class LoggingSystemProperties { @@ -300,35 +189,6 @@ public class LoggingSystemProperties {
return input;
}
/**
* Set a system property.
* @param resolver the resolver used to get the property value
* @param systemPropertyName the system property name
* @param propertyName the application property name
* @deprecated since 3.2.0 for removal in 3.4.0 with no replacement
*/
@Deprecated(since = "3.2.0", forRemoval = true)
protected final void setSystemProperty(PropertyResolver resolver, String systemPropertyName, String propertyName) {
setSystemProperty(resolver, systemPropertyName, propertyName, null);
}
/**
* Set a system property.
* @param resolver the resolver used to get the property value
* @param systemPropertyName the system property name
* @param propertyName the application property name
* @param defaultValue the default value if none can be resolved
* @deprecated since 3.2.0 for removal in 3.4.0 with no replacement
*/
@Deprecated(since = "3.2.0", forRemoval = true)
protected final void setSystemProperty(PropertyResolver resolver, String systemPropertyName, String propertyName,
String defaultValue) {
String value = resolver.getProperty(propertyName);
value = (value != null) ? value : this.defaultValueResolver.apply(systemPropertyName);
value = (value != null) ? value : defaultValue;
setSystemProperty(systemPropertyName, value);
}
/**
* Set a system property.
* @param name the property name

53
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -43,57 +43,6 @@ public class LogbackLoggingSystemProperties extends LoggingSystemProperties { @@ -43,57 +43,6 @@ public class LogbackLoggingSystemProperties extends LoggingSystemProperties {
private static final boolean JBOSS_LOGGING_PRESENT = ClassUtils.isPresent("org.jboss.logging.Logger",
LogbackLoggingSystemProperties.class.getClassLoader());
/**
* The name of the System property that contains the rolled-over log file name
* pattern.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link RollingPolicySystemProperty#getEnvironmentVariableName()} on
* {@link RollingPolicySystemProperty#FILE_NAME_PATTERN}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String ROLLINGPOLICY_FILE_NAME_PATTERN = RollingPolicySystemProperty.FILE_NAME_PATTERN
.getEnvironmentVariableName();
/**
* The name of the System property that contains the clean history on start flag.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link RollingPolicySystemProperty#getEnvironmentVariableName()} on
* {@link RollingPolicySystemProperty#CLEAN_HISTORY_ON_START}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String ROLLINGPOLICY_CLEAN_HISTORY_ON_START = RollingPolicySystemProperty.CLEAN_HISTORY_ON_START
.getEnvironmentVariableName();
/**
* The name of the System property that contains the file log max size.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link RollingPolicySystemProperty#getEnvironmentVariableName()} on
* {@link RollingPolicySystemProperty#MAX_FILE_SIZE}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String ROLLINGPOLICY_MAX_FILE_SIZE = RollingPolicySystemProperty.MAX_FILE_SIZE
.getEnvironmentVariableName();
/**
* The name of the System property that contains the file total size cap.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link RollingPolicySystemProperty#getEnvironmentVariableName()} on
* {@link RollingPolicySystemProperty#TOTAL_SIZE_CAP}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String ROLLINGPOLICY_TOTAL_SIZE_CAP = RollingPolicySystemProperty.TOTAL_SIZE_CAP
.getEnvironmentVariableName();
/**
* The name of the System property that contains the file log max history.
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of calling
* {@link RollingPolicySystemProperty#getEnvironmentVariableName()} on
* {@link RollingPolicySystemProperty#MAX_HISTORY}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public static final String ROLLINGPOLICY_MAX_HISTORY = RollingPolicySystemProperty.MAX_HISTORY
.getEnvironmentVariableName();
public LogbackLoggingSystemProperties(Environment environment) {
super(environment);
}

30
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreBundle.java

@ -52,22 +52,7 @@ public class PemSslStoreBundle implements SslStoreBundle { @@ -52,22 +52,7 @@ public class PemSslStoreBundle implements SslStoreBundle {
* @param trustStoreDetails the trust store details
*/
public PemSslStoreBundle(PemSslStoreDetails keyStoreDetails, PemSslStoreDetails trustStoreDetails) {
this(keyStoreDetails, trustStoreDetails, null);
}
/**
* Create a new {@link PemSslStoreBundle} instance.
* @param keyStoreDetails the key store details
* @param trustStoreDetails the trust store details
* @param alias the alias to use or {@code null} to use a default alias
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link PemSslStoreDetails#alias()} in the {@code keyStoreDetails} and
* {@code trustStoreDetails}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public PemSslStoreBundle(PemSslStoreDetails keyStoreDetails, PemSslStoreDetails trustStoreDetails, String alias) {
this.keyStore = createKeyStore("key", PemSslStore.load(keyStoreDetails), alias);
this.trustStore = createKeyStore("trust", PemSslStore.load(trustStoreDetails), alias);
this(PemSslStore.load(keyStoreDetails), PemSslStore.load(trustStoreDetails));
}
/**
@ -77,12 +62,8 @@ public class PemSslStoreBundle implements SslStoreBundle { @@ -77,12 +62,8 @@ public class PemSslStoreBundle implements SslStoreBundle {
* @since 3.2.0
*/
public PemSslStoreBundle(PemSslStore pemKeyStore, PemSslStore pemTrustStore) {
this(pemKeyStore, pemTrustStore, null);
}
private PemSslStoreBundle(PemSslStore pemKeyStore, PemSslStore pemTrustStore, String alias) {
this.keyStore = createKeyStore("key", pemKeyStore, alias);
this.trustStore = createKeyStore("trust", pemTrustStore, alias);
this.keyStore = createKeyStore("key", pemKeyStore);
this.trustStore = createKeyStore("trust", pemTrustStore);
}
@Override
@ -100,14 +81,13 @@ public class PemSslStoreBundle implements SslStoreBundle { @@ -100,14 +81,13 @@ public class PemSslStoreBundle implements SslStoreBundle {
return this.trustStore;
}
private static KeyStore createKeyStore(String name, PemSslStore pemSslStore, String alias) {
private static KeyStore createKeyStore(String name, PemSslStore pemSslStore) {
if (pemSslStore == null) {
return null;
}
try {
Assert.notEmpty(pemSslStore.certificates(), "Certificates must not be empty");
alias = (pemSslStore.alias() != null) ? pemSslStore.alias() : alias;
alias = (alias != null) ? alias : DEFAULT_ALIAS;
String alias = (pemSslStore.alias() != null) ? pemSslStore.alias() : DEFAULT_ALIAS;
KeyStore store = createKeyStore(pemSslStore.type());
List<X509Certificate> certificates = pemSslStore.certificates();
PrivateKey privateKey = pemSslStore.privateKey();

12
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -89,16 +89,6 @@ public record PemSslStoreDetails(String type, String alias, String password, Str @@ -89,16 +89,6 @@ public record PemSslStoreDetails(String type, String alias, String password, Str
this(type, certificate, privateKey, null);
}
/**
* Return the certificate content.
* @return the certificate content
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of {@link #certificates()}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public String certificate() {
return certificates();
}
/**
* Return a new {@link PemSslStoreDetails} instance with a new alias.
* @param alias the new alias

330
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorBuilder.java

@ -1,330 +0,0 @@ @@ -1,330 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.core.task.TaskDecorator;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
* Builder that can be used to configure and create a {@link TaskExecutor}. Provides
* convenience methods to set common {@link ThreadPoolTaskExecutor} settings and register
* {@link #taskDecorator(TaskDecorator)}). For advanced configuration, consider using
* {@link TaskExecutorCustomizer}.
* <p>
* In a typical auto-configured Spring Boot application this builder is available as a
* bean and can be injected whenever a {@link TaskExecutor} is needed.
*
* @author Stephane Nicoll
* @author Filip Hrisafov
* @since 2.1.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link ThreadPoolTaskExecutorBuilder}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
public class TaskExecutorBuilder {
private final Integer queueCapacity;
private final Integer corePoolSize;
private final Integer maxPoolSize;
private final Boolean allowCoreThreadTimeOut;
private final Duration keepAlive;
private final Boolean awaitTermination;
private final Duration awaitTerminationPeriod;
private final String threadNamePrefix;
private final TaskDecorator taskDecorator;
private final Set<TaskExecutorCustomizer> customizers;
public TaskExecutorBuilder() {
this.queueCapacity = null;
this.corePoolSize = null;
this.maxPoolSize = null;
this.allowCoreThreadTimeOut = null;
this.keepAlive = null;
this.awaitTermination = null;
this.awaitTerminationPeriod = null;
this.threadNamePrefix = null;
this.taskDecorator = null;
this.customizers = null;
}
private TaskExecutorBuilder(Integer queueCapacity, Integer corePoolSize, Integer maxPoolSize,
Boolean allowCoreThreadTimeOut, Duration keepAlive, Boolean awaitTermination,
Duration awaitTerminationPeriod, String threadNamePrefix, TaskDecorator taskDecorator,
Set<TaskExecutorCustomizer> customizers) {
this.queueCapacity = queueCapacity;
this.corePoolSize = corePoolSize;
this.maxPoolSize = maxPoolSize;
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
this.keepAlive = keepAlive;
this.awaitTermination = awaitTermination;
this.awaitTerminationPeriod = awaitTerminationPeriod;
this.threadNamePrefix = threadNamePrefix;
this.taskDecorator = taskDecorator;
this.customizers = customizers;
}
/**
* Set the capacity of the queue. An unbounded capacity does not increase the pool and
* therefore ignores {@link #maxPoolSize(int) maxPoolSize}.
* @param queueCapacity the queue capacity to set
* @return a new builder instance
*/
public TaskExecutorBuilder queueCapacity(int queueCapacity) {
return new TaskExecutorBuilder(queueCapacity, this.corePoolSize, this.maxPoolSize, this.allowCoreThreadTimeOut,
this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix,
this.taskDecorator, this.customizers);
}
/**
* Set the core number of threads. Effectively that maximum number of threads as long
* as the queue is not full.
* <p>
* Core threads can grow and shrink if {@link #allowCoreThreadTimeOut(boolean)} is
* enabled.
* @param corePoolSize the core pool size to set
* @return a new builder instance
*/
public TaskExecutorBuilder corePoolSize(int corePoolSize) {
return new TaskExecutorBuilder(this.queueCapacity, corePoolSize, this.maxPoolSize, this.allowCoreThreadTimeOut,
this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix,
this.taskDecorator, this.customizers);
}
/**
* Set the maximum allowed number of threads. When the {@link #queueCapacity(int)
* queue} is full, the pool can expand up to that size to accommodate the load.
* <p>
* If the {@link #queueCapacity(int) queue capacity} is unbounded, this setting is
* ignored.
* @param maxPoolSize the max pool size to set
* @return a new builder instance
*/
public TaskExecutorBuilder maxPoolSize(int maxPoolSize) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, maxPoolSize, this.allowCoreThreadTimeOut,
this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix,
this.taskDecorator, this.customizers);
}
/**
* Set whether core threads are allowed to time out. When enabled, this enables
* dynamic growing and shrinking of the pool.
* @param allowCoreThreadTimeOut if core threads are allowed to time out
* @return a new builder instance
*/
public TaskExecutorBuilder allowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize, allowCoreThreadTimeOut,
this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod, this.threadNamePrefix,
this.taskDecorator, this.customizers);
}
/**
* Set the time limit for which threads may remain idle before being terminated.
* @param keepAlive the keep alive to set
* @return a new builder instance
*/
public TaskExecutorBuilder keepAlive(Duration keepAlive) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, keepAlive, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.taskDecorator, this.customizers);
}
/**
* Set whether the executor should wait for scheduled tasks to complete on shutdown,
* not interrupting running tasks and executing all tasks in the queue.
* @param awaitTermination whether the executor needs to wait for the tasks to
* complete on shutdown
* @return a new builder instance
* @see #awaitTerminationPeriod(Duration)
*/
public TaskExecutorBuilder awaitTermination(boolean awaitTermination) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.taskDecorator, this.customizers);
}
/**
* Set the maximum time the executor is supposed to block on shutdown. When set, the
* executor blocks on shutdown in order to wait for remaining tasks to complete their
* execution before the rest of the container continues to shut down. This is
* particularly useful if your remaining tasks are likely to need access to other
* resources that are also managed by the container.
* @param awaitTerminationPeriod the await termination period to set
* @return a new builder instance
*/
public TaskExecutorBuilder awaitTerminationPeriod(Duration awaitTerminationPeriod) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, awaitTerminationPeriod,
this.threadNamePrefix, this.taskDecorator, this.customizers);
}
/**
* Set the prefix to use for the names of newly created threads.
* @param threadNamePrefix the thread name prefix to set
* @return a new builder instance
*/
public TaskExecutorBuilder threadNamePrefix(String threadNamePrefix) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod,
threadNamePrefix, this.taskDecorator, this.customizers);
}
/**
* Set the {@link TaskDecorator} to use or {@code null} to not use any.
* @param taskDecorator the task decorator to use
* @return a new builder instance
*/
public TaskExecutorBuilder taskDecorator(TaskDecorator taskDecorator) {
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, taskDecorator, this.customizers);
}
/**
* Set the {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be
* applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order
* that they were added after builder configuration has been applied. Setting this
* value will replace any previously configured customizers.
* @param customizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskExecutorCustomizer...)
*/
public TaskExecutorBuilder customizers(TaskExecutorCustomizer... customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return customizers(Arrays.asList(customizers));
}
/**
* Set the {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be
* applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order
* that they were added after builder configuration has been applied. Setting this
* value will replace any previously configured customizers.
* @param customizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskExecutorCustomizer...)
*/
public TaskExecutorBuilder customizers(Iterable<TaskExecutorCustomizer> customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.taskDecorator, append(null, customizers));
}
/**
* Add {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied
* to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param customizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskExecutorCustomizer...)
*/
public TaskExecutorBuilder additionalCustomizers(TaskExecutorCustomizer... customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return additionalCustomizers(Arrays.asList(customizers));
}
/**
* Add {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied
* to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param customizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskExecutorCustomizer...)
*/
public TaskExecutorBuilder additionalCustomizers(Iterable<TaskExecutorCustomizer> customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return new TaskExecutorBuilder(this.queueCapacity, this.corePoolSize, this.maxPoolSize,
this.allowCoreThreadTimeOut, this.keepAlive, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.taskDecorator, append(this.customizers, customizers));
}
/**
* Build a new {@link ThreadPoolTaskExecutor} instance and configure it using this
* builder.
* @return a configured {@link ThreadPoolTaskExecutor} instance.
* @see #build(Class)
* @see #configure(ThreadPoolTaskExecutor)
*/
public ThreadPoolTaskExecutor build() {
return configure(new ThreadPoolTaskExecutor());
}
/**
* Build a new {@link ThreadPoolTaskExecutor} instance of the specified type and
* configure it using this builder.
* @param <T> the type of task executor
* @param taskExecutorClass the template type to create
* @return a configured {@link ThreadPoolTaskExecutor} instance.
* @see #build()
* @see #configure(ThreadPoolTaskExecutor)
*/
public <T extends ThreadPoolTaskExecutor> T build(Class<T> taskExecutorClass) {
return configure(BeanUtils.instantiateClass(taskExecutorClass));
}
/**
* Configure the provided {@link ThreadPoolTaskExecutor} instance using this builder.
* @param <T> the type of task executor
* @param taskExecutor the {@link ThreadPoolTaskExecutor} to configure
* @return the task executor instance
* @see #build()
* @see #build(Class)
*/
public <T extends ThreadPoolTaskExecutor> T configure(T taskExecutor) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.queueCapacity).to(taskExecutor::setQueueCapacity);
map.from(this.corePoolSize).to(taskExecutor::setCorePoolSize);
map.from(this.maxPoolSize).to(taskExecutor::setMaxPoolSize);
map.from(this.keepAlive).asInt(Duration::getSeconds).to(taskExecutor::setKeepAliveSeconds);
map.from(this.allowCoreThreadTimeOut).to(taskExecutor::setAllowCoreThreadTimeOut);
map.from(this.awaitTermination).to(taskExecutor::setWaitForTasksToCompleteOnShutdown);
map.from(this.awaitTerminationPeriod).as(Duration::toMillis).to(taskExecutor::setAwaitTerminationMillis);
map.from(this.threadNamePrefix).whenHasText().to(taskExecutor::setThreadNamePrefix);
map.from(this.taskDecorator).to(taskExecutor::setTaskDecorator);
if (!CollectionUtils.isEmpty(this.customizers)) {
this.customizers.forEach((customizer) -> customizer.customize(taskExecutor));
}
return taskExecutor;
}
private <T> Set<T> append(Set<T> set, Iterable<? extends T> additions) {
Set<T> result = new LinkedHashSet<>((set != null) ? set : Collections.emptySet());
additions.forEach(result::add);
return Collections.unmodifiableSet(result);
}
}

40
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorCustomizer.java

@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* Callback interface that can be used to customize a {@link ThreadPoolTaskExecutor}.
*
* @author Stephane Nicoll
* @since 2.1.0
* @see TaskExecutorBuilder
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link ThreadPoolTaskExecutorCustomizer}
*/
@FunctionalInterface
@Deprecated(since = "3.2.0", forRemoval = true)
public interface TaskExecutorCustomizer {
/**
* Callback to customize a {@link ThreadPoolTaskExecutor} instance.
* @param taskExecutor the task executor to customize
*/
void customize(ThreadPoolTaskExecutor taskExecutor);
}

213
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerBuilder.java

@ -1,213 +0,0 @@ @@ -1,213 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
* Builder that can be used to configure and create a {@link TaskScheduler}. Provides
* convenience methods to set common {@link ThreadPoolTaskScheduler} settings. For
* advanced configuration, consider using {@link TaskSchedulerCustomizer}.
* <p>
* In a typical auto-configured Spring Boot application this builder is available as a
* bean and can be injected whenever a {@link TaskScheduler} is needed.
*
* @author Stephane Nicoll
* @since 2.1.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link ThreadPoolTaskSchedulerBuilder}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
public class TaskSchedulerBuilder {
private final Integer poolSize;
private final Boolean awaitTermination;
private final Duration awaitTerminationPeriod;
private final String threadNamePrefix;
private final Set<TaskSchedulerCustomizer> customizers;
public TaskSchedulerBuilder() {
this.poolSize = null;
this.awaitTermination = null;
this.awaitTerminationPeriod = null;
this.threadNamePrefix = null;
this.customizers = null;
}
public TaskSchedulerBuilder(Integer poolSize, Boolean awaitTermination, Duration awaitTerminationPeriod,
String threadNamePrefix, Set<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
this.poolSize = poolSize;
this.awaitTermination = awaitTermination;
this.awaitTerminationPeriod = awaitTerminationPeriod;
this.threadNamePrefix = threadNamePrefix;
this.customizers = taskSchedulerCustomizers;
}
/**
* Set the maximum allowed number of threads.
* @param poolSize the pool size to set
* @return a new builder instance
*/
public TaskSchedulerBuilder poolSize(int poolSize) {
return new TaskSchedulerBuilder(poolSize, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.customizers);
}
/**
* Set whether the executor should wait for scheduled tasks to complete on shutdown,
* not interrupting running tasks and executing all tasks in the queue.
* @param awaitTermination whether the executor needs to wait for the tasks to
* complete on shutdown
* @return a new builder instance
* @see #awaitTerminationPeriod(Duration)
*/
public TaskSchedulerBuilder awaitTermination(boolean awaitTermination) {
return new TaskSchedulerBuilder(this.poolSize, awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, this.customizers);
}
/**
* Set the maximum time the executor is supposed to block on shutdown. When set, the
* executor blocks on shutdown in order to wait for remaining tasks to complete their
* execution before the rest of the container continues to shut down. This is
* particularly useful if your remaining tasks are likely to need access to other
* resources that are also managed by the container.
* @param awaitTerminationPeriod the await termination period to set
* @return a new builder instance
*/
public TaskSchedulerBuilder awaitTerminationPeriod(Duration awaitTerminationPeriod) {
return new TaskSchedulerBuilder(this.poolSize, this.awaitTermination, awaitTerminationPeriod,
this.threadNamePrefix, this.customizers);
}
/**
* Set the prefix to use for the names of newly created threads.
* @param threadNamePrefix the thread name prefix to set
* @return a new builder instance
*/
public TaskSchedulerBuilder threadNamePrefix(String threadNamePrefix) {
return new TaskSchedulerBuilder(this.poolSize, this.awaitTermination, this.awaitTerminationPeriod,
threadNamePrefix, this.customizers);
}
/**
* Set the {@link TaskSchedulerCustomizer TaskSchedulerCustomizers} that should be
* applied to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the
* order that they were added after builder configuration has been applied. Setting
* this value will replace any previously configured customizers.
* @param customizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskSchedulerCustomizer...)
*/
public TaskSchedulerBuilder customizers(TaskSchedulerCustomizer... customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return customizers(Arrays.asList(customizers));
}
/**
* Set the {@link TaskSchedulerCustomizer taskSchedulerCustomizers} that should be
* applied to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the
* order that they were added after builder configuration has been applied. Setting
* this value will replace any previously configured customizers.
* @param customizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskSchedulerCustomizer...)
*/
public TaskSchedulerBuilder customizers(Iterable<TaskSchedulerCustomizer> customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return new TaskSchedulerBuilder(this.poolSize, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, append(null, customizers));
}
/**
* Add {@link TaskSchedulerCustomizer taskSchedulerCustomizers} that should be applied
* to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param customizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskSchedulerCustomizer...)
*/
public TaskSchedulerBuilder additionalCustomizers(TaskSchedulerCustomizer... customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return additionalCustomizers(Arrays.asList(customizers));
}
/**
* Add {@link TaskSchedulerCustomizer taskSchedulerCustomizers} that should be applied
* to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param customizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskSchedulerCustomizer...)
*/
public TaskSchedulerBuilder additionalCustomizers(Iterable<TaskSchedulerCustomizer> customizers) {
Assert.notNull(customizers, "Customizers must not be null");
return new TaskSchedulerBuilder(this.poolSize, this.awaitTermination, this.awaitTerminationPeriod,
this.threadNamePrefix, append(this.customizers, customizers));
}
/**
* Build a new {@link ThreadPoolTaskScheduler} instance and configure it using this
* builder.
* @return a configured {@link ThreadPoolTaskScheduler} instance.
* @see #configure(ThreadPoolTaskScheduler)
*/
public ThreadPoolTaskScheduler build() {
return configure(new ThreadPoolTaskScheduler());
}
/**
* Configure the provided {@link ThreadPoolTaskScheduler} instance using this builder.
* @param <T> the type of task scheduler
* @param taskScheduler the {@link ThreadPoolTaskScheduler} to configure
* @return the task scheduler instance
* @see #build()
*/
public <T extends ThreadPoolTaskScheduler> T configure(T taskScheduler) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.poolSize).to(taskScheduler::setPoolSize);
map.from(this.awaitTermination).to(taskScheduler::setWaitForTasksToCompleteOnShutdown);
map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds).to(taskScheduler::setAwaitTerminationSeconds);
map.from(this.threadNamePrefix).to(taskScheduler::setThreadNamePrefix);
if (!CollectionUtils.isEmpty(this.customizers)) {
this.customizers.forEach((customizer) -> customizer.customize(taskScheduler));
}
return taskScheduler;
}
private <T> Set<T> append(Set<T> set, Iterable<? extends T> additions) {
Set<T> result = new LinkedHashSet<>((set != null) ? set : Collections.emptySet());
additions.forEach(result::add);
return Collections.unmodifiableSet(result);
}
}

39
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerCustomizer.java

@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* Callback interface that can be used to customize a {@link ThreadPoolTaskScheduler}.
*
* @author Stephane Nicoll
* @since 2.1.0
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link ThreadPoolTaskSchedulerCustomizer}
*/
@FunctionalInterface
@Deprecated(since = "3.2.0", forRemoval = true)
public interface TaskSchedulerCustomizer {
/**
* Callback to customize a {@link ThreadPoolTaskScheduler} instance.
* @param taskScheduler the task scheduler to customize
*/
void customize(ThreadPoolTaskScheduler taskScheduler);
}

56
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactorySettings.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,36 +40,7 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration @@ -40,36 +40,7 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration
* the implementation.
*/
public static final ClientHttpRequestFactorySettings DEFAULTS = new ClientHttpRequestFactorySettings(null, null,
null, null);
/**
* Create a new {@link ClientHttpRequestFactorySettings} instance.
* @param connectTimeout the connection timeout
* @param readTimeout the read timeout
* @param bufferRequestBody if request body buffering is used
* @deprecated since 3.2.0 for removal in 3.4.0 as support for buffering has been
* removed in Spring Framework 6.1
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public ClientHttpRequestFactorySettings(Duration connectTimeout, Duration readTimeout, Boolean bufferRequestBody) {
this(connectTimeout, readTimeout, (SslBundle) null);
}
/**
* Create a new {@link ClientHttpRequestFactorySettings} instance.
* @param connectTimeout the connection timeout
* @param readTimeout the read timeout
* @param bufferRequestBody if request body buffering is used
* @param sslBundle the ssl bundle
* @since 3.1.0
* @deprecated since 3.2.0 for removal in 3.4.0 as support for buffering has been
* removed in Spring Framework 6.1
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public ClientHttpRequestFactorySettings(Duration connectTimeout, Duration readTimeout, Boolean bufferRequestBody,
SslBundle sslBundle) {
this(connectTimeout, readTimeout, sslBundle);
}
null);
/**
* Return a new {@link ClientHttpRequestFactorySettings} instance with an updated
@ -92,18 +63,6 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration @@ -92,18 +63,6 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration
return new ClientHttpRequestFactorySettings(this.connectTimeout, readTimeout, this.sslBundle);
}
/**
* Has no effect as support for buffering has been removed in Spring Framework 6.1.
* @param bufferRequestBody the new buffer request body setting
* @return a new {@link ClientHttpRequestFactorySettings} instance
* @deprecated since 3.2.0 for removal in 3.4.0 as support for buffering has been
* removed in Spring Framework 6.1
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public ClientHttpRequestFactorySettings withBufferRequestBody(Boolean bufferRequestBody) {
return this;
}
/**
* Return a new {@link ClientHttpRequestFactorySettings} instance with an updated SSL
* bundle setting.
@ -115,15 +74,4 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration @@ -115,15 +74,4 @@ public record ClientHttpRequestFactorySettings(Duration connectTimeout, Duration
return new ClientHttpRequestFactorySettings(this.connectTimeout, this.readTimeout, sslBundle);
}
/**
* Returns whether request body buffering is used.
* @return whether request body buffering is used
* @deprecated since 3.2.0 for removal in 3.4.0 as support for buffering has been
* removed in Spring Framework 6.1
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public Boolean bufferRequestBody() {
return null;
}
}

17
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java

@ -35,8 +35,6 @@ import org.springframework.boot.ssl.SslBundle; @@ -35,8 +35,6 @@ import org.springframework.boot.ssl.SslBundle;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@ -436,21 +434,6 @@ public class RestTemplateBuilder { @@ -436,21 +434,6 @@ public class RestTemplateBuilder {
this.customizers, this.requestCustomizers);
}
/**
* Has no effect as support for buffering has been removed in Spring Framework 6.1.
* @param bufferRequestBody value of the bufferRequestBody parameter
* @return a new builder instance.
* @since 2.2.0
* @deprecated since 3.2.0 for removal in 3.4.0 as support for buffering has been
* removed in Spring Framework 6.1
* @see SimpleClientHttpRequestFactory#setBufferRequestBody(boolean)
* @see HttpComponentsClientHttpRequestFactory#setBufferRequestBody(boolean)
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public RestTemplateBuilder setBufferRequestBody(boolean bufferRequestBody) {
return this;
}
/**
* Sets the SSL bundle on the underlying {@link ClientHttpRequestFactory}.
* @param sslBundle the SSL bundle

6
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriBuilderFactory.java

@ -31,12 +31,6 @@ import org.springframework.web.util.UriTemplateHandler; @@ -31,12 +31,6 @@ import org.springframework.web.util.UriTemplateHandler;
*/
public class RootUriBuilderFactory extends RootUriTemplateHandler implements UriBuilderFactory {
@SuppressWarnings("removal")
RootUriBuilderFactory(String rootUri) {
super(rootUri);
}
@SuppressWarnings("removal")
RootUriBuilderFactory(String rootUri, UriTemplateHandler delegate) {
super(rootUri, delegate);
}

50
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java

@ -18,12 +18,9 @@ package org.springframework.boot.web.client; @@ -18,12 +18,9 @@ package org.springframework.boot.web.client;
import java.net.URI;
import java.util.Map;
import java.util.function.Function;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriTemplateHandler;
/**
@ -45,24 +42,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { @@ -45,24 +42,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
this.handler = handler;
}
/**
* Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to be used to prefix relative URLs
* @deprecated since 3.2.3 for removal in 3.4.0, with no replacement
*/
@Deprecated(since = "3.2.3", forRemoval = true)
public RootUriTemplateHandler(String rootUri) {
this(rootUri, new DefaultUriBuilderFactory());
}
/**
* Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to be used to prefix relative URLs
* @param handler the handler handler
* @deprecated since 3.2.3 for removal in 3.4.0, with no replacement
*/
@Deprecated(since = "3.2.3", forRemoval = true)
public RootUriTemplateHandler(String rootUri, UriTemplateHandler handler) {
RootUriTemplateHandler(String rootUri, UriTemplateHandler handler) {
Assert.notNull(rootUri, "RootUri must not be null");
Assert.notNull(handler, "Handler must not be null");
this.rootUri = rootUri;
@ -90,32 +70,4 @@ public class RootUriTemplateHandler implements UriTemplateHandler { @@ -90,32 +70,4 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
return this.rootUri;
}
/**
* Derives a new {@code RootUriTemplateHandler} from this one, wrapping its delegate
* {@link UriTemplateHandler} by applying the given {@code wrapper}.
* @param wrapper the wrapper to apply to the delegate URI template handler
* @return the new handler
* @since 2.3.10
* @deprecated since 3.2.3 for removal in 3.4.0, with no replacement
*/
@Deprecated(since = "3.2.3", forRemoval = true)
public RootUriTemplateHandler withHandlerWrapper(Function<UriTemplateHandler, UriTemplateHandler> wrapper) {
return new RootUriTemplateHandler(getRootUri(), wrapper.apply(this.handler));
}
/**
* Add a {@link RootUriTemplateHandler} instance to the given {@link RestTemplate}.
* @param restTemplate the {@link RestTemplate} to add the handler to
* @param rootUri the root URI
* @return the added {@link RootUriTemplateHandler}.
* @deprecated since 3.2.3 for removal in 3.4.0, with no replacement
*/
@Deprecated(since = "3.2.3", forRemoval = true)
public static RootUriTemplateHandler addTo(RestTemplate restTemplate, String rootUri) {
Assert.notNull(restTemplate, "RestTemplate must not be null");
RootUriTemplateHandler handler = new RootUriTemplateHandler(rootUri, restTemplate.getUriTemplateHandler());
restTemplate.setUriTemplateHandler(handler);
return handler;
}
}

15
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java

@ -82,21 +82,6 @@ public class NettyWebServer implements WebServer { @@ -82,21 +82,6 @@ public class NettyWebServer implements WebServer {
private volatile DisposableServer disposableServer;
/**
* Creates a new {@code NettyWebServer} instance.
* @param httpServer the HTTP server
* @param handlerAdapter the handler adapter
* @param lifecycleTimeout the lifecycle timeout, may be {@code null}
* @param shutdown the shutdown, may be {@code null}
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #NettyWebServer(HttpServer, ReactorHttpHandlerAdapter, Duration, Shutdown, ReactorResourceFactory)}
*/
@Deprecated(since = "3.2.0", forRemoval = true)
public NettyWebServer(HttpServer httpServer, ReactorHttpHandlerAdapter handlerAdapter, Duration lifecycleTimeout,
Shutdown shutdown) {
this(httpServer, handlerAdapter, lifecycleTimeout, shutdown, null);
}
/**
* Creates a new {@code NettyWebServer} instance.
* @param httpServer the HTTP server

11
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java

@ -106,17 +106,6 @@ public class SslServerCustomizer implements NettyServerCustomizer { @@ -106,17 +106,6 @@ public class SslServerCustomizer implements NettyServerCustomizer {
return SslProvider.builder().sslContext((GenericSslContextSpec<?>) createSslContextSpec(sslBundle)).build();
}
/**
* Factory method used to create an {@link AbstractProtocolSslContextSpec}.
* @return the {@link AbstractProtocolSslContextSpec} to use
* @deprecated since 3.2.0 for removal in 3.4.0 in favor of
* {@link #createSslContextSpec(SslBundle)}
*/
@Deprecated(since = "3.2", forRemoval = true)
protected AbstractProtocolSslContextSpec<?> createSslContextSpec() {
return createSslContextSpec(this.sslBundle);
}
/**
* Create an {@link AbstractProtocolSslContextSpec} for a given {@link SslBundle}.
* @param sslBundle the {@link SslBundle} to use

2
spring-boot-project/spring-boot/src/main/resources/META-INF/spring.factories

@ -36,7 +36,6 @@ org.springframework.boot.diagnostics.FailureAnalyzers @@ -36,7 +36,6 @@ org.springframework.boot.diagnostics.FailureAnalyzers
org.springframework.context.ApplicationContextInitializer=\
org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer,\
org.springframework.boot.context.ContextIdApplicationContextInitializer,\
org.springframework.boot.context.config.DelegatingApplicationContextInitializer,\
org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer,\
org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer
@ -46,7 +45,6 @@ org.springframework.boot.ClearCachesApplicationListener,\ @@ -46,7 +45,6 @@ org.springframework.boot.ClearCachesApplicationListener,\
org.springframework.boot.builder.ParentContextCloserApplicationListener,\
org.springframework.boot.context.FileEncodingApplicationListener,\
org.springframework.boot.context.config.AnsiOutputApplicationListener,\
org.springframework.boot.context.config.DelegatingApplicationListener,\
org.springframework.boot.context.logging.LoggingApplicationListener,\
org.springframework.boot.env.EnvironmentPostProcessorApplicationListener

8
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -265,7 +265,7 @@ class SpringApplicationBuilderTests { @@ -265,7 +265,7 @@ class SpringApplicationBuilderTests {
SpringApplicationBuilder application = new SpringApplicationBuilder(ExampleConfig.class)
.web(WebApplicationType.NONE);
this.context = application.run();
assertThat(application.application().getInitializers()).hasSize(5);
assertThat(application.application().getInitializers()).hasSize(4);
}
@Test
@ -274,7 +274,7 @@ class SpringApplicationBuilderTests { @@ -274,7 +274,7 @@ class SpringApplicationBuilderTests {
.child(ChildConfig.class)
.web(WebApplicationType.NONE);
this.context = application.run();
assertThat(application.application().getInitializers()).hasSize(6);
assertThat(application.application().getInitializers()).hasSize(5);
}
@Test
@ -284,7 +284,7 @@ class SpringApplicationBuilderTests { @@ -284,7 +284,7 @@ class SpringApplicationBuilderTests {
.initializers((ConfigurableApplicationContext applicationContext) -> {
});
this.context = application.run();
assertThat(application.application().getInitializers()).hasSize(6);
assertThat(application.application().getInitializers()).hasSize(5);
}
@Test

123
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/DelegatingApplicationContextInitializerTests.java

@ -1,123 +0,0 @@ @@ -1,123 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.config;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.support.TestPropertySourceUtils;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Tests for {@link DelegatingApplicationContextInitializer}.
*
* @author Phillip Webb
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
class DelegatingApplicationContextInitializerTests {
private final DelegatingApplicationContextInitializer initializer = new DelegatingApplicationContextInitializer();
@Test
void orderedInitialize() {
StaticApplicationContext context = new StaticApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context,
"context.initializer.classes=" + MockInitB.class.getName() + "," + MockInitA.class.getName());
this.initializer.initialize(context);
assertThat(context.getBeanFactory().getSingleton("a")).isEqualTo("a");
assertThat(context.getBeanFactory().getSingleton("b")).isEqualTo("b");
}
@Test
void noInitializers() {
StaticApplicationContext context = new StaticApplicationContext();
this.initializer.initialize(context);
}
@Test
void emptyInitializers() {
StaticApplicationContext context = new StaticApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, "context.initializer.classes:");
this.initializer.initialize(context);
}
@Test
void noSuchInitializerClass() {
StaticApplicationContext context = new StaticApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context,
"context.initializer.classes=missing.madeup.class");
assertThatExceptionOfType(ApplicationContextException.class)
.isThrownBy(() -> this.initializer.initialize(context));
}
@Test
void notAnInitializerClass() {
StaticApplicationContext context = new StaticApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context,
"context.initializer.classes=" + Object.class.getName());
assertThatIllegalArgumentException().isThrownBy(() -> this.initializer.initialize(context));
}
@Test
void genericNotSuitable() {
StaticApplicationContext context = new StaticApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context,
"context.initializer.classes=" + NotSuitableInit.class.getName());
assertThatIllegalArgumentException().isThrownBy(() -> this.initializer.initialize(context))
.withMessageContaining("generic parameter");
}
@Order(Ordered.HIGHEST_PRECEDENCE)
static class MockInitA implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
applicationContext.getBeanFactory().registerSingleton("a", "a");
}
}
@Order(Ordered.LOWEST_PRECEDENCE)
static class MockInitB implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
assertThat(applicationContext.getBeanFactory().getSingleton("a")).isEqualTo("a");
applicationContext.getBeanFactory().registerSingleton("b", "b");
}
}
static class NotSuitableInit implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {
@Override
public void initialize(ConfigurableWebApplicationContext applicationContext) {
}
}
}

105
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/DelegatingApplicationListenerTests.java

@ -1,105 +0,0 @@ @@ -1,105 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.config;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.DefaultBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link DelegatingApplicationListener}.
*
* @author Dave Syer
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
class DelegatingApplicationListenerTests {
private final DelegatingApplicationListener listener = new DelegatingApplicationListener();
private final StaticApplicationContext context = new StaticApplicationContext();
@AfterEach
void close() {
if (this.context != null) {
this.context.close();
}
}
@Test
void orderedInitialize() {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
"context.listener.classes=" + MockInitB.class.getName() + "," + MockInitA.class.getName());
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new DefaultBootstrapContext(),
new SpringApplication(), new String[0], this.context.getEnvironment()));
this.context.getBeanFactory().registerSingleton("testListener", this.listener);
this.context.refresh();
assertThat(this.context.getBeanFactory().getSingleton("a")).isEqualTo("a");
assertThat(this.context.getBeanFactory().getSingleton("b")).isEqualTo("b");
}
@Test
void noInitializers() {
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new DefaultBootstrapContext(),
new SpringApplication(), new String[0], this.context.getEnvironment()));
}
@Test
void emptyInitializers() {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "context.listener.classes:");
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new DefaultBootstrapContext(),
new SpringApplication(), new String[0], this.context.getEnvironment()));
}
@Order(Ordered.HIGHEST_PRECEDENCE)
static class MockInitA implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) event
.getApplicationContext();
applicationContext.getBeanFactory().registerSingleton("a", "a");
}
}
@Order(Ordered.LOWEST_PRECEDENCE)
static class MockInitB implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) event
.getApplicationContext();
assertThat(applicationContext.getBeanFactory().getSingleton("a")).isEqualTo("a");
applicationContext.getBeanFactory().registerSingleton("b", "b");
}
}
}

20
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java

@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
package org.springframework.boot.logging.logback;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
@ -30,6 +28,7 @@ import java.util.Map; @@ -30,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Handler;
import java.util.logging.LogManager;
import java.util.stream.Stream;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
@ -69,7 +68,6 @@ import org.springframework.core.env.ConfigurableEnvironment; @@ -69,7 +68,6 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;
@ -550,20 +548,20 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { @@ -550,20 +548,20 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Map<String, String> properties = loggerContext.getCopyOfPropertyMap();
Set<String> expectedProperties = new HashSet<>();
ReflectionUtils.doWithFields(LogbackLoggingSystemProperties.class,
(field) -> expectedProperties.add((String) field.get(null)), this::isPublicStaticFinal);
expectedProperties.removeAll(Arrays.asList("LOG_FILE", "LOG_PATH"));
Stream.of(RollingPolicySystemProperty.values())
.map(RollingPolicySystemProperty::getEnvironmentVariableName)
.forEach(expectedProperties::add);
Stream.of(LoggingSystemProperty.values())
.map(LoggingSystemProperty::getEnvironmentVariableName)
.forEach(expectedProperties::add);
expectedProperties
.removeAll(Arrays.asList("LOG_FILE", "LOG_PATH", "LOGGED_APPLICATION_NAME", "LOGGED_APPLICATION_GROUP"));
expectedProperties.add("org.jboss.logging.provider");
expectedProperties.add("LOG_CORRELATION_PATTERN");
assertThat(properties).containsOnlyKeys(expectedProperties);
assertThat(properties).containsEntry("CONSOLE_LOG_CHARSET", Charset.defaultCharset().name());
}
private boolean isPublicStaticFinal(Field field) {
int modifiers = field.getModifiers();
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
}
@Test
void initializationIsOnlyPerformedOnceUntilCleanedUp() {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

14
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ssl/pem/PemSslStoreBundleTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -167,18 +167,6 @@ class PemSslStoreBundleTests { @@ -167,18 +167,6 @@ class PemSslStoreBundleTests {
assertThat(bundle.getTrustStore()).satisfies(storeContainingCertAndKey("ssl"));
}
@Test
@SuppressWarnings("removal")
void createWithDetailsWhenHasKeyStoreDetailsAndTrustStoreDetailsAndAlias() {
PemSslStoreDetails keyStoreDetails = PemSslStoreDetails.forCertificate("classpath:test-cert.pem")
.withPrivateKey("classpath:test-key.pem");
PemSslStoreDetails trustStoreDetails = PemSslStoreDetails.forCertificate("classpath:test-cert.pem")
.withPrivateKey("classpath:test-key.pem");
PemSslStoreBundle bundle = new PemSslStoreBundle(keyStoreDetails, trustStoreDetails, "test-alias");
assertThat(bundle.getKeyStore()).satisfies(storeContainingCertAndKey("test-alias"));
assertThat(bundle.getTrustStore()).satisfies(storeContainingCertAndKey("test-alias"));
}
@Test
void createWithDetailsWhenHasStoreType() {
PemSslStoreDetails keyStoreDetails = new PemSslStoreDetails("PKCS12", "classpath:test-cert.pem",

169
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java

@ -1,169 +0,0 @@ @@ -1,169 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import java.time.Duration;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
/**
* Tests for {@link TaskExecutorBuilder}.
*
* @author Stephane Nicoll
* @author Filip Hrisafov
*/
@SuppressWarnings("removal")
class TaskExecutorBuilderTests {
private final TaskExecutorBuilder builder = new TaskExecutorBuilder();
@Test
void poolSettingsShouldApply() {
ThreadPoolTaskExecutor executor = this.builder.queueCapacity(10)
.corePoolSize(4)
.maxPoolSize(8)
.allowCoreThreadTimeOut(true)
.keepAlive(Duration.ofMinutes(1))
.build();
assertThat(executor).hasFieldOrPropertyWithValue("queueCapacity", 10);
assertThat(executor.getCorePoolSize()).isEqualTo(4);
assertThat(executor.getMaxPoolSize()).isEqualTo(8);
assertThat(executor).hasFieldOrPropertyWithValue("allowCoreThreadTimeOut", true);
assertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
}
@Test
void awaitTerminationShouldApply() {
ThreadPoolTaskExecutor executor = this.builder.awaitTermination(true).build();
assertThat(executor).hasFieldOrPropertyWithValue("waitForTasksToCompleteOnShutdown", true);
}
@Test
void awaitTerminationPeriodShouldApplyWithMillisecondPrecision() {
Duration period = Duration.ofMillis(50);
ThreadPoolTaskExecutor executor = this.builder.awaitTerminationPeriod(period).build();
assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis());
}
@Test
void threadNamePrefixShouldApply() {
ThreadPoolTaskExecutor executor = this.builder.threadNamePrefix("test-").build();
assertThat(executor.getThreadNamePrefix()).isEqualTo("test-");
}
@Test
void taskDecoratorShouldApply() {
TaskDecorator taskDecorator = mock(TaskDecorator.class);
ThreadPoolTaskExecutor executor = this.builder.taskDecorator(taskDecorator).build();
assertThat(executor).extracting("taskDecorator").isSameAs(taskDecorator);
}
@Test
void customizersWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.builder.customizers((TaskExecutorCustomizer[]) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void customizersCollectionWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.customizers((Set<TaskExecutorCustomizer>) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void customizersShouldApply() {
TaskExecutorCustomizer customizer = mock(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = this.builder.customizers(customizer).build();
then(customizer).should().customize(executor);
}
@Test
void customizersShouldBeAppliedLast() {
TaskDecorator taskDecorator = mock(TaskDecorator.class);
ThreadPoolTaskExecutor executor = spy(new ThreadPoolTaskExecutor());
this.builder.queueCapacity(10)
.corePoolSize(4)
.maxPoolSize(8)
.allowCoreThreadTimeOut(true)
.keepAlive(Duration.ofMinutes(1))
.awaitTermination(true)
.awaitTerminationPeriod(Duration.ofSeconds(30))
.threadNamePrefix("test-")
.taskDecorator(taskDecorator)
.additionalCustomizers((taskExecutor) -> {
then(taskExecutor).should().setQueueCapacity(10);
then(taskExecutor).should().setCorePoolSize(4);
then(taskExecutor).should().setMaxPoolSize(8);
then(taskExecutor).should().setAllowCoreThreadTimeOut(true);
then(taskExecutor).should().setKeepAliveSeconds(60);
then(taskExecutor).should().setWaitForTasksToCompleteOnShutdown(true);
then(taskExecutor).should().setAwaitTerminationSeconds(30);
then(taskExecutor).should().setThreadNamePrefix("test-");
then(taskExecutor).should().setTaskDecorator(taskDecorator);
});
this.builder.configure(executor);
}
@Test
void customizersShouldReplaceExisting() {
TaskExecutorCustomizer customizer1 = mock(TaskExecutorCustomizer.class);
TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1)
.customizers(Collections.singleton(customizer2))
.build();
then(customizer1).shouldHaveNoInteractions();
then(customizer2).should().customize(executor);
}
@Test
void additionalCustomizersWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.additionalCustomizers((TaskExecutorCustomizer[]) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.additionalCustomizers((Set<TaskExecutorCustomizer>) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void additionalCustomizersShouldAddToExisting() {
TaskExecutorCustomizer customizer1 = mock(TaskExecutorCustomizer.class);
TaskExecutorCustomizer customizer2 = mock(TaskExecutorCustomizer.class);
ThreadPoolTaskExecutor executor = this.builder.customizers(customizer1)
.additionalCustomizers(customizer2)
.build();
then(customizer1).should().customize(executor);
then(customizer2).should().customize(executor);
}
}

135
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java

@ -1,135 +0,0 @@ @@ -1,135 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.task;
import java.time.Duration;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
/**
* Tests for {@link TaskSchedulerBuilder}.
*
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
class TaskSchedulerBuilderTests {
private final TaskSchedulerBuilder builder = new TaskSchedulerBuilder();
@Test
void poolSettingsShouldApply() {
ThreadPoolTaskScheduler scheduler = this.builder.poolSize(4).build();
assertThat(scheduler.getPoolSize()).isEqualTo(4);
}
@Test
void awaitTerminationShouldApply() {
ThreadPoolTaskScheduler executor = this.builder.awaitTermination(true).build();
assertThat(executor).hasFieldOrPropertyWithValue("waitForTasksToCompleteOnShutdown", true);
}
@Test
void awaitTerminationPeriodShouldApply() {
Duration period = Duration.ofMinutes(1);
ThreadPoolTaskScheduler executor = this.builder.awaitTerminationPeriod(period).build();
assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis());
}
@Test
void threadNamePrefixShouldApply() {
ThreadPoolTaskScheduler scheduler = this.builder.threadNamePrefix("test-").build();
assertThat(scheduler.getThreadNamePrefix()).isEqualTo("test-");
}
@Test
void customizersWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.customizers((TaskSchedulerCustomizer[]) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void customizersCollectionWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.customizers((Set<TaskSchedulerCustomizer>) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void customizersShouldApply() {
TaskSchedulerCustomizer customizer = mock(TaskSchedulerCustomizer.class);
ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer).build();
then(customizer).should().customize(scheduler);
}
@Test
void customizersShouldBeAppliedLast() {
ThreadPoolTaskScheduler scheduler = spy(new ThreadPoolTaskScheduler());
this.builder.poolSize(4).threadNamePrefix("test-").additionalCustomizers((taskScheduler) -> {
then(taskScheduler).should().setPoolSize(4);
then(taskScheduler).should().setThreadNamePrefix("test-");
});
this.builder.configure(scheduler);
}
@Test
void customizersShouldReplaceExisting() {
TaskSchedulerCustomizer customizer1 = mock(TaskSchedulerCustomizer.class);
TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class);
ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1)
.customizers(Collections.singleton(customizer2))
.build();
then(customizer1).shouldHaveNoInteractions();
then(customizer2).should().customize(scheduler);
}
@Test
void additionalCustomizersWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.additionalCustomizers((TaskSchedulerCustomizer[]) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.builder.additionalCustomizers((Set<TaskSchedulerCustomizer>) null))
.withMessageContaining("Customizers must not be null");
}
@Test
void additionalCustomizersShouldAddToExisting() {
TaskSchedulerCustomizer customizer1 = mock(TaskSchedulerCustomizer.class);
TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class);
ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1)
.additionalCustomizers(customizer2)
.build();
then(customizer1).should().customize(scheduler);
then(customizer2).should().customize(scheduler);
}
}

5
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriBuilderFactoryTests.java

@ -23,8 +23,10 @@ import org.junit.jupiter.api.Test; @@ -23,8 +23,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.web.util.UriBuilder;
import org.springframework.web.util.UriBuilderFactory;
import org.springframework.web.util.UriTemplateHandler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link RootUriBuilderFactory}.
@ -35,7 +37,8 @@ class RootUriBuilderFactoryTests { @@ -35,7 +37,8 @@ class RootUriBuilderFactoryTests {
@Test
void uriStringPrefixesRoot() throws URISyntaxException {
UriBuilderFactory builderFactory = new RootUriBuilderFactory("https://example.com");
UriBuilderFactory builderFactory = new RootUriBuilderFactory("https://example.com",
mock(UriTemplateHandler.class));
UriBuilder builder = builderFactory.uriString("/hello");
assertThat(builder.build()).isEqualTo(new URI("https://example.com/hello"));
}

18
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java

@ -27,7 +27,6 @@ import org.junit.jupiter.api.extension.ExtendWith; @@ -27,7 +27,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriTemplateHandler;
import static org.assertj.core.api.Assertions.assertThat;
@ -36,6 +35,7 @@ import static org.mockito.ArgumentMatchers.any; @@ -36,6 +35,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link RootUriTemplateHandler}.
@ -43,7 +43,6 @@ import static org.mockito.BDDMockito.then; @@ -43,7 +43,6 @@ import static org.mockito.BDDMockito.then;
* @author Phillip Webb
*/
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("removal")
class RootUriTemplateHandlerTests {
private URI uri;
@ -61,7 +60,8 @@ class RootUriTemplateHandlerTests { @@ -61,7 +60,8 @@ class RootUriTemplateHandlerTests {
@Test
void createWithNullRootUriShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new RootUriTemplateHandler((String) null))
assertThatIllegalArgumentException()
.isThrownBy(() -> new RootUriTemplateHandler((String) null, mock(UriTemplateHandler.class)))
.withMessageContaining("RootUri must not be null");
}
@ -109,16 +109,4 @@ class RootUriTemplateHandlerTests { @@ -109,16 +109,4 @@ class RootUriTemplateHandlerTests {
assertThat(expanded).isEqualTo(this.uri);
}
@Test
void applyShouldWrapExistingTemplate() {
given(this.delegate.expand(anyString(), any(Object[].class))).willReturn(this.uri);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setUriTemplateHandler(this.delegate);
this.handler = RootUriTemplateHandler.addTo(restTemplate, "https://example.com");
Object[] uriVariables = new Object[0];
URI expanded = this.handler.expand("/hello", uriVariables);
then(this.delegate).should().expand("https://example.com/hello", uriVariables);
assertThat(expanded).isEqualTo(this.uri);
}
}

Loading…
Cancel
Save