Skip to content

Commit

Permalink
Return default for empty environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
roulpriya committed Oct 10, 2022
1 parent 09c42a4 commit 2526659
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -230,7 +230,10 @@ private String getConfigurable(
}

if (environment.containsKey(envVarName)) {
return environment.get(envVarName);
String value = environment.get(envVarName);
if(!value.isEmpty()) {
return value;
}
}

for (final Properties properties : propertiesSources) {
Expand Down
Expand Up @@ -125,6 +125,16 @@ public void shouldReadDockerSettingsFromUserProperties() {
.as("reads unprefixed user properties for docker. settings")
.isEqualTo("some value");
}
@Test
public void shouldNotReadSettingIfCorrespondingEnvironmentVarIsEmptyString() {

environment.put("DOCKER_FOO", "");
assertThat(newConfig().getEnvVarOrUserProperty("docker.foo", "default"))
.as("reads unprefixed env vars for docker. settings")
.isEqualTo("default");


}

@Test
public void shouldNotReadDockerClientStrategyFromClasspathProperties() {
Expand Down

0 comments on commit 2526659

Please sign in to comment.