Skip to content

Commit

Permalink
Merge pull request #7530 from geoand/dot-env-always
Browse files Browse the repository at this point in the history
Make sure that DotEnvConfigSource is used for runtime properties as well
  • Loading branch information
gsmet authored Mar 3, 2020
2 parents f1abb07 + 5ecb677 commit 093094a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
Expand Down Expand Up @@ -69,7 +70,7 @@ public static SmallRyeConfigBuilder configBuilder(final boolean runTime, final b
final ApplicationPropertiesConfigSource.InFileSystem inFileSystem = new ApplicationPropertiesConfigSource.InFileSystem();
final ApplicationPropertiesConfigSource.InJar inJar = new ApplicationPropertiesConfigSource.InJar();
final ApplicationPropertiesConfigSource.MpConfigInJar mpConfig = new ApplicationPropertiesConfigSource.MpConfigInJar();
builder.withSources(inFileSystem, inJar, mpConfig);
builder.withSources(inFileSystem, inJar, mpConfig, new DotEnvConfigSource());
final ExpandingConfigSource.Cache cache = new ExpandingConfigSource.Cache();
builder.withWrapper(ExpandingConfigSource.wrapper(cache));
builder.withWrapper(DeploymentProfileConfigSource.wrapper());
Expand All @@ -84,7 +85,6 @@ public static SmallRyeConfigBuilder configBuilder(final boolean runTime, final b
sources.addAll(
new PropertiesConfigSourceProvider("WEB-INF/classes/META-INF/microprofile-config.properties", true,
classLoader).getConfigSources(classLoader));
sources.add(new DotEnvConfigSource());
sources.add(new EnvConfigSource());
sources.add(new SysPropConfigSource());
builder.withSources(sources);
Expand Down Expand Up @@ -121,7 +121,9 @@ public static void addSourceProviders(SmallRyeConfigBuilder builder, Collection<
}
}

static class EnvConfigSource implements ConfigSource {
static class EnvConfigSource implements ConfigSource, Serializable {
private static final long serialVersionUID = 8786096039970882529L;

static final Pattern REP_PATTERN = Pattern.compile("[^a-zA-Z0-9_]");

EnvConfigSource() {
Expand Down Expand Up @@ -149,6 +151,8 @@ public String getName() {
}

static class DotEnvConfigSource extends EnvConfigSource {
private static final long serialVersionUID = -6718168105190376482L;

private final Map<String, String> values;

DotEnvConfigSource() {
Expand Down

0 comments on commit 093094a

Please sign in to comment.