Merge branch '3.4.x'

Closes gh-44685
This commit is contained in:
Stéphane Nicoll 2025-03-12 08:59:09 +01:00
commit 3ea9c56ea0
20 changed files with 36 additions and 44 deletions

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.data.redis; package org.springframework.boot.actuate.autoconfigure.data.redis;
import java.util.Map;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@ -51,8 +49,7 @@ import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
public class RedisReactiveHealthContributorAutoConfiguration extends public class RedisReactiveHealthContributorAutoConfiguration extends
CompositeReactiveHealthContributorConfiguration<RedisReactiveHealthIndicator, ReactiveRedisConnectionFactory> { CompositeReactiveHealthContributorConfiguration<RedisReactiveHealthIndicator, ReactiveRedisConnectionFactory> {
RedisReactiveHealthContributorAutoConfiguration( RedisReactiveHealthContributorAutoConfiguration() {
Map<String, ReactiveRedisConnectionFactory> redisConnectionFactories) {
super(RedisReactiveHealthIndicator::new); super(RedisReactiveHealthIndicator::new);
} }

View File

@ -123,13 +123,11 @@ abstract class AbstractCompositeHealthContributorConfigurationTests<C, I extends
@Bean(defaultCandidate = false) @Bean(defaultCandidate = false)
TestBean nonDefault() { TestBean nonDefault() {
return new TestBean(); return new TestBean();
} }
@Bean(autowireCandidate = false) @Bean(autowireCandidate = false)
TestBean nonAutowire() { TestBean nonAutowire() {
return new TestBean(); return new TestBean();
} }
} }
@ -145,7 +143,6 @@ abstract class AbstractCompositeHealthContributorConfigurationTests<C, I extends
@Bean(autowireCandidate = false) @Bean(autowireCandidate = false)
TestBean nonAutowire() { TestBean nonAutowire() {
return new TestBean(); return new TestBean();
} }
} }

View File

@ -60,7 +60,7 @@ class SanitizingFunctionTests {
void ifLikelySensitiveFiltersExpected() { void ifLikelySensitiveFiltersExpected() {
SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitive(); SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitive();
assertThat(function).satisfies(this::likelyCredentialChecks, this::likelyUriChecks, assertThat(function).satisfies(this::likelyCredentialChecks, this::likelyUriChecks,
this::likelySenstivePropertyChecks, this::vcapServicesChecks); this::likelySensitivePropertyChecks, this::vcapServicesChecks);
} }
@Test @Test
@ -103,10 +103,10 @@ class SanitizingFunctionTests {
@Test @Test
void ifLikelySensitivePropertyFiltersExpected() { void ifLikelySensitivePropertyFiltersExpected() {
SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitiveProperty(); SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitiveProperty();
assertThat(function).satisfies(this::likelySenstivePropertyChecks); assertThat(function).satisfies(this::likelySensitivePropertyChecks);
} }
private void likelySenstivePropertyChecks(SanitizingFunction function) { private void likelySensitivePropertyChecks(SanitizingFunction function) {
assertThatApplyingToKey(function, "sun.java.command").has(sanitizedValue()); assertThatApplyingToKey(function, "sun.java.command").has(sanitizedValue());
assertThatApplyingToKey(function, "spring.application.json").has(sanitizedValue()); assertThatApplyingToKey(function, "spring.application.json").has(sanitizedValue());
assertThatApplyingToKey(function, "SPRING_APPLICATION_JSON").has(sanitizedValue()); assertThatApplyingToKey(function, "SPRING_APPLICATION_JSON").has(sanitizedValue());

View File

@ -44,7 +44,7 @@ import org.springframework.context.annotation.DependsOn;
public @interface AutoConfigureBefore { public @interface AutoConfigureBefore {
/** /**
* The auto-configure classes that should have not yet been applied. * The auto-configuration classes that should have not yet been applied.
* @return the classes * @return the classes
*/ */
Class<?>[] value() default {}; Class<?>[] value() default {};

View File

@ -79,7 +79,6 @@ class CassandraReactiveDataAutoConfigurationTests {
@Test @Test
void userTypeResolverShouldBeSet() { void userTypeResolverShouldBeSet() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(CassandraConverter.class);
assertThat(context).hasSingleBean(CassandraConverter.class); assertThat(context).hasSingleBean(CassandraConverter.class);
assertThat(context.getBean(CassandraConverter.class)).extracting("userTypeResolver") assertThat(context.getBean(CassandraConverter.class)).extracting("userTypeResolver")
.isInstanceOf(SimpleUserTypeResolver.class); .isInstanceOf(SimpleUserTypeResolver.class);

View File

@ -142,13 +142,12 @@ class LdapAutoConfigurationTests {
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:389").run((context) -> { this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:389").run((context) -> {
assertThat(context).hasSingleBean(ObjectDirectoryMapper.class); assertThat(context).hasSingleBean(ObjectDirectoryMapper.class);
ObjectDirectoryMapper objectDirectoryMapper = context.getBean(ObjectDirectoryMapper.class); ObjectDirectoryMapper objectDirectoryMapper = context.getBean(ObjectDirectoryMapper.class);
ApplicationConversionService conversionService = assertThat(objectDirectoryMapper) assertThat(objectDirectoryMapper).extracting("converterManager")
.extracting("converterManager") .extracting("conversionService", InstanceOfAssertFactories.type(ApplicationConversionService.class))
.extracting("conversionService") .satisfies((conversionService) -> {
.asInstanceOf(InstanceOfAssertFactories.type(ApplicationConversionService.class)) assertThat(conversionService.canConvert(String.class, Name.class)).isTrue();
.actual(); assertThat(conversionService.canConvert(Name.class, String.class)).isTrue();
assertThat(conversionService.canConvert(String.class, Name.class)).isTrue(); });
assertThat(conversionService.canConvert(Name.class, String.class)).isTrue();
}); });
} }

View File

@ -300,7 +300,7 @@ public class Builder {
} }
/** /**
* Creates{@link DockerLog} instance based on the provided {@link BuildLog}. * Creates {@link DockerLog} instance based on the provided {@link BuildLog}.
* <p> * <p>
* If the provided {@link BuildLog} instance is an {@link AbstractBuildLog}, the * If the provided {@link BuildLog} instance is an {@link AbstractBuildLog}, the
* method returns a {@link BuildLogAdapter}, otherwise it returns a default * method returns a {@link BuildLogAdapter}, otherwise it returns a default

View File

@ -87,7 +87,7 @@ public class DockerApi {
* Create a new {@link DockerApi} instance. * Create a new {@link DockerApi} instance.
*/ */
public DockerApi() { public DockerApi() {
this(HttpTransport.create(null), DockerLog.toSystemOut()); this(null);
} }
/** /**
@ -96,7 +96,7 @@ public class DockerApi {
* @since 2.4.0 * @since 2.4.0
*/ */
public DockerApi(DockerHostConfiguration dockerHost) { public DockerApi(DockerHostConfiguration dockerHost) {
this(HttpTransport.create(dockerHost), DockerLog.toSystemOut()); this(dockerHost, DockerLog.toSystemOut());
} }
/** /**

View File

@ -34,7 +34,7 @@ public interface DockerLog {
void log(String message); void log(String message);
/** /**
* Factory method that returns a {@link DockerLog} the outputs to {@link System#out}. * Factory method that returns a {@link DockerLog} that outputs to {@link System#out}.
* @return {@link DockerLog} instance that logs to system out * @return {@link DockerLog} instance that logs to system out
*/ */
static DockerLog toSystemOut() { static DockerLog toSystemOut() {
@ -42,7 +42,7 @@ public interface DockerLog {
} }
/** /**
* Factory method that returns a {@link DockerLog} the outputs to a given * Factory method that returns a {@link DockerLog} that outputs to a given
* {@link PrintStream}. * {@link PrintStream}.
* @param out the print stream used to output the log * @param out the print stream used to output the log
* @return {@link DockerLog} instance that logs to the given print stream * @return {@link DockerLog} instance that logs to the given print stream

View File

@ -47,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.isNull;
@ -73,14 +74,12 @@ class BuilderTests {
@Test @Test
void createWithDockerConfiguration() { void createWithDockerConfiguration() {
Builder builder = new Builder(BuildLog.toSystemOut()); assertThatNoException().isThrownBy(() -> new Builder(BuildLog.toSystemOut()));
assertThat(builder).isNotNull();
} }
@Test @Test
void createDockerApiWithLogDockerLogDelegate() { void createDockerApiWithLogDockerLogDelegate() {
Builder builder = new Builder(BuildLog.toSystemOut()); Builder builder = new Builder(BuildLog.toSystemOut());
assertThat(builder).isNotNull();
assertThat(builder).extracting("docker") assertThat(builder).extracting("docker")
.extracting("system") .extracting("system")
.extracting("log") .extracting("log")
@ -90,7 +89,6 @@ class BuilderTests {
@Test @Test
void createDockerApiWithLogDockerSystemOutDelegate() { void createDockerApiWithLogDockerSystemOutDelegate() {
Builder builder = new Builder(mock(BuildLog.class)); Builder builder = new Builder(mock(BuildLog.class));
assertThat(builder).isNotNull();
assertThat(builder).extracting("docker") assertThat(builder).extracting("docker")
.extracting("system") .extracting("system")
.extracting("log") .extracting("log")

View File

@ -447,7 +447,7 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem {
super.cleanUp(); super.cleanUp();
LoggerContext loggerContext = getLoggerContext(); LoggerContext loggerContext = getLoggerContext();
markAsUninitialized(loggerContext); markAsUninitialized(loggerContext);
StatusConsoleListener listener = (StatusConsoleListener) getLoggerContext().getObject(STATUS_LISTENER_KEY); StatusConsoleListener listener = (StatusConsoleListener) loggerContext.getObject(STATUS_LISTENER_KEY);
if (listener != null) { if (listener != null) {
StatusLogger.getLogger().removeListener(listener); StatusLogger.getLogger().removeListener(listener);
loggerContext.removeObject(STATUS_LISTENER_KEY); loggerContext.removeObject(STATUS_LISTENER_KEY);

View File

@ -146,15 +146,15 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
super.refresh(); super.refresh();
} }
catch (RuntimeException ex) { catch (RuntimeException ex) {
try { WebServer webServer = this.webServer;
WebServer webServer = this.webServer; if (webServer != null) {
if (webServer != null) { try {
webServer.stop(); webServer.stop();
webServer.destroy(); webServer.destroy();
} }
} catch (RuntimeException stopOrDestroyEx) {
catch (RuntimeException stopOrDestroyEx) { ex.addSuppressed(stopOrDestroyEx);
ex.addSuppressed(stopOrDestroyEx); }
} }
throw ex; throw ex;
} }

View File

@ -187,7 +187,7 @@ class StructuredLoggingJsonPropertiesTests {
} }
@Test @Test
void shouldReturnFalseWhenPrinterIsEmpty() { void hasCustomPrinterShouldReturnFalseWhenPrinterIsEmpty() {
StackTrace stackTrace = new StackTrace("", null, null, null, null, null); StackTrace stackTrace = new StackTrace("", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isFalse(); assertThat(stackTrace.hasCustomPrinter()).isFalse();
} }

View File

@ -44,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
/** /**
@ -148,7 +149,7 @@ class ReactiveWebServerApplicationContextTests {
.withStackTraceContaining("WebServer has failed to stop"); .withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer(); WebServer webServer = this.context.getWebServer();
then(webServer).should().stop(); then(webServer).should().stop();
then(webServer).should(times(0)).destroy(); then(webServer).should(never()).destroy();
} }
@Test @Test

View File

@ -86,6 +86,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.withSettings; import static org.mockito.Mockito.withSettings;
@ -236,7 +237,7 @@ class ServletWebServerApplicationContextTests {
.withStackTraceContaining("WebServer has failed to stop"); .withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer(); WebServer webServer = this.context.getWebServer();
then(webServer).should().stop(); then(webServer).should().stop();
then(webServer).should(times(0)).destroy(); then(webServer).should(never()).destroy();
} }
@Test @Test

View File

@ -169,7 +169,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.never;
/** /**
* Base for testing classes that extends {@link AbstractServletWebServerFactory}. * Base for testing classes that extends {@link AbstractServletWebServerFactory}.
@ -1193,7 +1193,7 @@ public abstract class AbstractServletWebServerFactoryTests {
this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener)); this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener));
this.webServer.start(); this.webServer.start();
this.webServer.stop(); this.webServer.stop();
then(listener).should(times(0)).contextDestroyed(any(ServletContextEvent.class)); then(listener).should(never()).contextDestroyed(any(ServletContextEvent.class));
} }
@Test @Test

View File

@ -4,7 +4,7 @@ plugins {
id "org.springframework.boot.docker-test" id "org.springframework.boot.docker-test"
} }
description = "Spring Boot Data ElasticSearch smoke test" description = "Spring Boot Data Elasticsearch smoke test"
dependencies { dependencies {
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))

View File

@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest @DataElasticsearchTest
class SampleElasticSearch8ApplicationTests { class SampleElasticsearch8ApplicationTests {
@Container @Container
@ServiceConnection @ServiceConnection

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest @DataElasticsearchTest
class SampleElasticSearchApplicationTests { class SampleElasticsearchApplicationTests {
@Container @Container
@ServiceConnection @ServiceConnection

View File

@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest( @DataElasticsearchTest(
properties = { "spring.elasticsearch.connection-timeout=120s", "spring.elasticsearch.socket-timeout=120s" }) properties = { "spring.elasticsearch.connection-timeout=120s", "spring.elasticsearch.socket-timeout=120s" })
class SampleElasticSearchSslApplicationTests { class SampleElasticsearchSslApplicationTests {
@Container @Container
@ServiceConnection @ServiceConnection