Skip to content

Commit

Permalink
ConfigFactory.invalidateCaches() also resets environment variables co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
Cameron Mullen committed Mar 22, 2017
1 parent 180d66b commit 0659ab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public static void invalidateCaches() {
// We rely on this having the side effect that it drops
// all caches
ConfigImpl.reloadSystemPropertiesConfig();
ConfigImpl.reloadEnvVariablesConfig();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private static AbstractConfigObject loadEnvVariables() {
}

private static class EnvVariablesHolder {
static final AbstractConfigObject envVariables = loadEnvVariables();
static volatile AbstractConfigObject envVariables = loadEnvVariables();
}

static AbstractConfigObject envVariablesAsConfigObject() {
Expand All @@ -354,6 +354,12 @@ public static Config envVariablesAsConfig() {
return envVariablesAsConfigObject().toConfig();
}

public static void reloadEnvVariablesConfig() {
// ConfigFactory.invalidateCaches() relies on this having the side
// effect that it drops all caches
EnvVariablesHolder.envVariables = loadEnvVariables();
}

public static Config defaultReference(final ClassLoader loader) {
return computeCachedConfig(loader, "defaultReference", new Callable<Config>() {
@Override
Expand Down

0 comments on commit 0659ab5

Please sign in to comment.