From a07ef13ff5388527e95df9c2ec240c02c6328ea6 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sun, 30 Mar 2025 11:26:53 +0900 Subject: [PATCH] Polish Signed-off-by: Johnny Lim --- .../OpenTelemetryResourceAttributes.java | 4 +- ...FoundryActuatorAutoConfigurationTests.java | 137 ++++++++---------- .../HealthEndpointAutoConfigurationTests.java | 3 - ...lpMetricsPropertiesConfigAdapterTests.java | 2 +- .../autoconfigure/jdbc/JdbcProperties.java | 2 +- .../autoconfigure/web/ServerProperties.java | 2 +- .../GraphQlAutoConfigurationTests.java | 13 +- ...toConfigurationWithoutSpringJdbcTests.java | 19 +-- ...DockerComposeConnectionDetailsFactory.java | 2 +- .../pages/actuator/observability.adoc | 2 +- .../context/config/FileExtensionHint.java | 2 +- .../boot/jdbc/EmbeddedDatabaseConnection.java | 6 +- 12 files changed, 79 insertions(+), 115 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributes.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributes.java index f68d14f3fd9b..0de23c1a2deb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributes.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributes.java @@ -57,7 +57,7 @@ public final class OpenTelemetryResourceAttributes { /** * Creates a new instance of {@link OpenTelemetryResourceAttributes}. * @param environment the environment - * @param resourceAttributes user provided resource attributes to be used + * @param resourceAttributes user-provided resource attributes to be used */ public OpenTelemetryResourceAttributes(Environment environment, Map resourceAttributes) { this(environment, resourceAttributes, null); @@ -66,7 +66,7 @@ public OpenTelemetryResourceAttributes(Environment environment, Map resourceAttributes, diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index 2a0e7adceea7..e020ace3c1ac 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -27,6 +27,7 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import reactor.netty.http.HttpResources; @@ -43,7 +44,6 @@ import org.springframework.boot.actuate.endpoint.EndpointId; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; -import org.springframework.boot.actuate.endpoint.web.EndpointMapping; import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint; import org.springframework.boot.actuate.endpoint.web.WebOperation; import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate; @@ -74,7 +74,6 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.security.web.server.WebFilterChainProxy; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.reactive.function.client.WebClient; @@ -121,16 +120,16 @@ void cloudFoundryPlatformActive() { "vcap.application.cf_api:https://my-cloud-controller.com") .run((context) -> { CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); - EndpointMapping endpointMapping = (EndpointMapping) ReflectionTestUtils.getField(handlerMapping, - "endpointMapping"); - assertThat(endpointMapping.getPath()).isEqualTo("/cloudfoundryapplication"); - CorsConfiguration corsConfiguration = (CorsConfiguration) ReflectionTestUtils.getField(handlerMapping, - "corsConfiguration"); - assertThat(corsConfiguration.getAllowedOrigins()).contains("*"); - assertThat(corsConfiguration.getAllowedMethods()) - .containsAll(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name())); - assertThat(corsConfiguration.getAllowedHeaders()) - .containsAll(Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type")); + assertThat(handlerMapping).extracting("endpointMapping.path").isEqualTo("/cloudfoundryapplication"); + assertThat(handlerMapping) + .extracting("corsConfiguration", InstanceOfAssertFactories.type(CorsConfiguration.class)) + .satisfies((corsConfiguration) -> { + assertThat(corsConfiguration.getAllowedOrigins()).contains("*"); + assertThat(corsConfiguration.getAllowedMethods()) + .containsAll(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name())); + assertThat(corsConfiguration.getAllowedHeaders()) + .containsAll(Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type")); + }); }); } @@ -150,12 +149,8 @@ void cloudFoundryPlatformActiveSetsApplicationId() { this.contextRunner .withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com") - .run((context) -> { - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); - Object interceptor = ReflectionTestUtils.getField(handlerMapping, "securityInterceptor"); - String applicationId = (String) ReflectionTestUtils.getField(interceptor, "applicationId"); - assertThat(applicationId).isEqualTo("my-app-id"); - }); + .run((context) -> assertThat(getHandlerMapping(context)).extracting("securityInterceptor.applicationId") + .isEqualTo("my-app-id")); } @Test @@ -163,28 +158,18 @@ void cloudFoundryPlatformActiveSetsCloudControllerUrl() { this.contextRunner .withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com") - .run((context) -> { - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); - Object interceptor = ReflectionTestUtils.getField(handlerMapping, "securityInterceptor"); - Object interceptorSecurityService = ReflectionTestUtils.getField(interceptor, - "cloudFoundrySecurityService"); - String cloudControllerUrl = (String) ReflectionTestUtils.getField(interceptorSecurityService, - "cloudControllerUrl"); - assertThat(cloudControllerUrl).isEqualTo("https://my-cloud-controller.com"); - }); + .run((context) -> assertThat(getHandlerMapping(context)) + .extracting("securityInterceptor.cloudFoundrySecurityService.cloudControllerUrl") + .isEqualTo("https://my-cloud-controller.com")); } @Test void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent() { this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id") - .run((context) -> { - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = context.getBean( - "cloudFoundryWebFluxEndpointHandlerMapping", CloudFoundryWebFluxEndpointHandlerMapping.class); - Object securityInterceptor = ReflectionTestUtils.getField(handlerMapping, "securityInterceptor"); - Object interceptorSecurityService = ReflectionTestUtils.getField(securityInterceptor, - "cloudFoundrySecurityService"); - assertThat(interceptorSecurityService).isNull(); - }); + .run((context) -> assertThat(context.getBean("cloudFoundryWebFluxEndpointHandlerMapping", + CloudFoundryWebFluxEndpointHandlerMapping.class)) + .extracting("securityInterceptor.cloudFoundrySecurityService") + .isNull()); } @Test @@ -194,30 +179,30 @@ void cloudFoundryPathsIgnoredBySpringSecurity() { .withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com") .run((context) -> { - WebFilterChainProxy chainProxy = context.getBean(WebFilterChainProxy.class); - List filters = (List) ReflectionTestUtils - .getField(chainProxy, "filters"); - Boolean cfBaseRequestMatches = getMatches(filters, BASE_PATH); - Boolean cfBaseWithTrailingSlashRequestMatches = getMatches(filters, BASE_PATH + "/"); - Boolean cfRequestMatches = getMatches(filters, BASE_PATH + "/test"); - Boolean cfRequestWithAdditionalPathMatches = getMatches(filters, BASE_PATH + "/test/a"); - Boolean otherCfRequestMatches = getMatches(filters, BASE_PATH + "/other-path"); - Boolean otherRequestMatches = getMatches(filters, "/some-other-path"); - assertThat(cfBaseRequestMatches).isTrue(); - assertThat(cfBaseWithTrailingSlashRequestMatches).isTrue(); - assertThat(cfRequestMatches).isTrue(); - assertThat(cfRequestWithAdditionalPathMatches).isTrue(); - assertThat(otherCfRequestMatches).isFalse(); - assertThat(otherRequestMatches).isFalse(); - otherRequestMatches = filters.get(1) - .matches(MockServerWebExchange.from(MockServerHttpRequest.get("/some-other-path").build())) - .block(Duration.ofSeconds(30)); - assertThat(otherRequestMatches).isTrue(); + assertThat(context.getBean(WebFilterChainProxy.class)) + .extracting("filters", InstanceOfAssertFactories.list(SecurityWebFilterChain.class)) + .satisfies((filters) -> { + Boolean cfBaseRequestMatches = getMatches(filters, BASE_PATH); + Boolean cfBaseWithTrailingSlashRequestMatches = getMatches(filters, BASE_PATH + "/"); + Boolean cfRequestMatches = getMatches(filters, BASE_PATH + "/test"); + Boolean cfRequestWithAdditionalPathMatches = getMatches(filters, BASE_PATH + "/test/a"); + Boolean otherCfRequestMatches = getMatches(filters, BASE_PATH + "/other-path"); + Boolean otherRequestMatches = getMatches(filters, "/some-other-path"); + assertThat(cfBaseRequestMatches).isTrue(); + assertThat(cfBaseWithTrailingSlashRequestMatches).isTrue(); + assertThat(cfRequestMatches).isTrue(); + assertThat(cfRequestWithAdditionalPathMatches).isTrue(); + assertThat(otherCfRequestMatches).isFalse(); + assertThat(otherRequestMatches).isFalse(); + otherRequestMatches = filters.get(1) + .matches(MockServerWebExchange.from(MockServerHttpRequest.get("/some-other-path").build())) + .block(Duration.ofSeconds(30)); + assertThat(otherRequestMatches).isTrue(); + }); }); - } - private static Boolean getMatches(List filters, String urlTemplate) { + private static Boolean getMatches(List filters, String urlTemplate) { return filters.get(0) .matches(MockServerWebExchange.from(MockServerHttpRequest.get(urlTemplate).build())) .block(Duration.ofSeconds(30)); @@ -322,20 +307,17 @@ void skipSslValidation() throws IOException { .withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com", "management.cloudfoundry.skip-ssl-validation:true") - .run((context) -> { - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); - Object interceptor = ReflectionTestUtils.getField(handlerMapping, "securityInterceptor"); - Object interceptorSecurityService = ReflectionTestUtils.getField(interceptor, - "cloudFoundrySecurityService"); - WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService, - "webClient"); - ResponseEntity response = webClient.get() - .uri(server.url("/").uri()) - .retrieve() - .toBodilessEntity() - .block(Duration.ofSeconds(30)); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(204)); - }); + .run((context) -> assertThat(getHandlerMapping(context)) + .extracting("securityInterceptor.cloudFoundrySecurityService.webClient", + InstanceOfAssertFactories.type(WebClient.class)) + .satisfies((webClient) -> { + ResponseEntity response = webClient.get() + .uri(server.url("/").uri()) + .retrieve() + .toBodilessEntity() + .block(Duration.ofSeconds(30)); + assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(204)); + })); } } @@ -351,21 +333,16 @@ void sslValidationNotSkippedByDefault() throws IOException { this.contextRunner.withConfiguration(AutoConfigurations.of(HealthEndpointAutoConfiguration.class)) .withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", "vcap.application.cf_api:https://my-cloud-controller.com") - .run((context) -> { - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); - Object interceptor = ReflectionTestUtils.getField(handlerMapping, "securityInterceptor"); - Object interceptorSecurityService = ReflectionTestUtils.getField(interceptor, - "cloudFoundrySecurityService"); - WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService, - "webClient"); - assertThatExceptionOfType(RuntimeException.class) + .run((context) -> assertThat(getHandlerMapping(context)) + .extracting("securityInterceptor.cloudFoundrySecurityService.webClient", + InstanceOfAssertFactories.type(WebClient.class)) + .satisfies((webClient) -> assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> webClient.get() .uri(server.url("/").uri()) .retrieve() .toBodilessEntity() .block(Duration.ofSeconds(30))) - .withCauseInstanceOf(SSLException.class); - }); + .withCauseInstanceOf(SSLException.class))); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java index d1144387ac2a..3a836c878bbb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java @@ -53,9 +53,7 @@ import org.springframework.boot.actuate.health.StatusAggregator; import org.springframework.boot.actuate.health.SystemHealth; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; @@ -365,7 +363,6 @@ void additionalJerseyHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExpos .withClassLoader(new FilteredClassLoader(DispatcherServlet.class)) .withPropertyValues("management.endpoints.web.exposure.exclude=*", "management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry") - .withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)) .run((context) -> { assertThat(context).hasSingleBean(JerseyAdditionalHealthEndpointPathsConfiguration.class); assertThat(context).hasNotFailed(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapterTests.java index 93ef9fa3f5f7..cd067216b177 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapterTests.java @@ -63,7 +63,7 @@ void whenPropertiesUrlIsNotSetAdapterUrlReturnsDefault() { } @Test - void whenPropertiesUrlIsNotSetThanUseOtlpConfigUrlAsFallback() { + void whenPropertiesUrlIsNotSetThenUseOtlpConfigUrlAsFallback() { assertThat(this.properties.getUrl()).isNull(); OtlpMetricsPropertiesConfigAdapter adapter = spy(createAdapter()); given(adapter.get("management.otlp.metrics.export.url")).willReturn("https://my-endpoint/v1/metrics"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java index 7d879e882fc0..6c9a1ab412c0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcProperties.java @@ -45,7 +45,7 @@ public static class Template { /** * Whether to ignore JDBC statement warnings (SQLWarning). When set to false, - * throw a SQLWarningException instead. + * throw an SQLWarningException instead. */ private boolean ignoreWarnings = true; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 97bf7e0f3a62..9702d8fe72ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -1156,7 +1156,7 @@ public enum UseApr { WHEN_AVAILABLE, /** - * Never user APR. + * Never use APR. */ NEVER diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java index 40efbbf41264..7fe6c2ac94f4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java @@ -35,9 +35,7 @@ import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration.GraphQlResourcesRuntimeHints; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; @@ -89,12 +87,11 @@ class GraphQlAutoConfigurationTests { @Test void shouldContributeDefaultBeans() { - this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)) - .run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class) - .hasSingleBean(BatchLoaderRegistry.class) - .hasSingleBean(ExecutionGraphQlService.class) - .hasSingleBean(AnnotatedControllerConfigurer.class) - .hasSingleBean(EncodingCursorStrategy.class)); + this.contextRunner.run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class) + .hasSingleBean(BatchLoaderRegistry.class) + .hasSingleBean(ExecutionGraphQlService.class) + .hasSingleBean(AnnotatedControllerConfigurer.class) + .hasSingleBean(EncodingCursorStrategy.class)); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationWithoutSpringJdbcTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationWithoutSpringJdbcTests.java index df6f394e95ce..9f0c5ece982e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationWithoutSpringJdbcTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationWithoutSpringJdbcTests.java @@ -25,8 +25,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; -import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; @@ -46,25 +44,22 @@ class DataSourceAutoConfigurationWithoutSpringJdbcTests { @Test void pooledDataSourceCanBeAutoConfigured() { - this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)) - .run((context) -> { - HikariDataSource dataSource = context.getBean(HikariDataSource.class); - assertThat(dataSource.getJdbcUrl()).isNotNull(); - assertThat(dataSource.getDriverClassName()).isNotNull(); - }); + this.contextRunner.run((context) -> { + HikariDataSource dataSource = context.getBean(HikariDataSource.class); + assertThat(dataSource.getJdbcUrl()).isNotNull(); + assertThat(dataSource.getDriverClassName()).isNotNull(); + }); } @Test void withoutConnectionPoolsAutoConfigurationBacksOff() { - this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)) - .with(hideConnectionPools()) + this.contextRunner.with(hideConnectionPools()) .run((context) -> assertThat(context).doesNotHaveBean(DataSource.class)); } @Test void withUrlAndWithoutConnectionPoolsAutoConfigurationBacksOff() { - this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)) - .with(hideConnectionPools()) + this.contextRunner.with(hideConnectionPools()) .withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()) .run((context) -> assertThat(context).doesNotHaveBean(DataSource.class)); } diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/ldap/LLdapDockerComposeConnectionDetailsFactory.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/ldap/LLdapDockerComposeConnectionDetailsFactory.java index 406efe000cba..0c72c224adfd 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/ldap/LLdapDockerComposeConnectionDetailsFactory.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/ldap/LLdapDockerComposeConnectionDetailsFactory.java @@ -31,7 +31,7 @@ */ class LLdapDockerComposeConnectionDetailsFactory extends DockerComposeConnectionDetailsFactory { - protected LLdapDockerComposeConnectionDetailsFactory() { + LLdapDockerComposeConnectionDetailsFactory() { super("lldap/lldap"); } diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/observability.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/observability.adoc index 2a37108a344a..f74fff89fc2f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/observability.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/observability.adoc @@ -104,7 +104,7 @@ If you have defined your own javadoc:io.opentelemetry.sdk.resources.Resource[] b NOTE: Spring Boot does not provide auto-configuration for OpenTelemetry metrics or logging. OpenTelemetry tracing is only auto-configured when used together with xref:actuator/tracing.adoc[Micrometer Tracing]. -NOTE: The `OTEL_RESOURCE_ATTRIBUTES` environment variable consist of a list of key-value pairs. +NOTE: The `OTEL_RESOURCE_ATTRIBUTES` environment variable consists of a list of key-value pairs. For example: `key1=value1,key2=value2,key3=spring%20boot`. All attribute values are treated as strings, and any characters outside the baggage-octet range must be **percent-encoded**. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/FileExtensionHint.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/FileExtensionHint.java index 42c70d74e61b..f57d0b51e231 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/FileExtensionHint.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/FileExtensionHint.java @@ -20,7 +20,7 @@ import java.util.regex.Pattern; /** - * User provided hint for an otherwise missing file extension. + * User-provided hint for an otherwise missing file extension. * * @author Phillip Webb */ diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java index 143e23a22f52..f54608a5cfdc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java @@ -163,10 +163,8 @@ private static EmbeddedDatabaseConnection getEmbeddedDatabaseConnection(String d * @return true if the data source is one of the embedded types */ public static boolean isEmbedded(DataSource dataSource) { - try { - try (Connection connection = dataSource.getConnection()) { - return new IsEmbedded().apply(connection); - } + try (Connection connection = dataSource.getConnection()) { + return new IsEmbedded().apply(connection); } catch (SQLException ex) { // Could not connect, which means it's not embedded