Skip to content

Commit ab8d2eb

Browse files
hezeanwilkinsona
authored andcommitted
Make handling of ALLOW_EMPTY_PASSWORD consistent
See gh-43790 Signed-off-by: He Zean <realhezean@gmail.com>
1 parent f2906a0 commit ab8d2eb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/clickhouse/ClickHouseEnvironment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ class ClickHouseEnvironment {
4141
}
4242

4343
private String extractPassword(Map<String, String> env) {
44-
boolean allowEmpty = Boolean.parseBoolean(env.getOrDefault("ALLOW_EMPTY_PASSWORD", Boolean.FALSE.toString()));
44+
boolean allowEmpty = env.containsKey("ALLOW_EMPTY_PASSWORD");
4545
String password = env.get("CLICKHOUSE_PASSWORD");
4646
Assert.state(StringUtils.hasLength(password) || allowEmpty, "No ClickHouse password found");
4747
return (password != null) ? password : "";

spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/clickhouse/ClickHouseEnvironmentTests.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,10 +50,9 @@ void getPasswordWhenHasNoPasswordAndAllowEmptyPassword() {
5050
}
5151

5252
@Test
53-
void getPasswordWhenHasNoPasswordAndAllowEmptyPasswordIsFalse() {
54-
assertThatIllegalStateException()
55-
.isThrownBy(() -> new ClickHouseEnvironment(Map.of("ALLOW_EMPTY_PASSWORD", "false")))
56-
.withMessage("No ClickHouse password found");
53+
void getPasswordWhenHasNoPasswordAndAllowEmptyPasswordIsYes() {
54+
ClickHouseEnvironment environment = new ClickHouseEnvironment(Map.of("ALLOW_EMPTY_PASSWORD", "yes"));
55+
assertThat(environment.getPassword()).isEmpty();
5756
}
5857

5958
@Test

0 commit comments

Comments
 (0)