Skip to content

Commit 5854d45

Browse files
committed
Revert "javalite-1393 Implement ability to fall through from AppConfig property file to System.getenv() w..."
This reverts commit 3cddeb6.
1 parent 0f0cf1a commit 5854d45

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

app-config/src/main/java/org/javalite/app_config/AppConfig.java

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -204,28 +204,14 @@ public static void reload(){
204204
private static void overloadFromSystemEnv() {
205205
Map<String, String> sysEnv = new HashMap<>();
206206
for (String key: props.keySet()){
207-
String val = System.getenv(propertyNameToEnvVarName(key));
207+
String val = System.getenv(key.replace(".", "_").replace("-", "_").toUpperCase());
208208
if(!blank(val)){
209209
sysEnv.put(key, val);
210210
}
211211
}
212212
registerMap(sysEnv, "System.getenv()");
213213
}
214214

215-
/**
216-
* Translates a property name to an environment variable name.
217-
* A typical Java property name uses lower case words punctuated by dots:
218-
* <code>server.port</code>. However, environment variables typically use upper case
219-
* characters and cannot have dots in a name. This method converts property names to environment variable names:
220-
* <code>server.port</code> is converted to <code>SERVER_PORT</code>
221-
* @param propName name of a Java property
222-
*
223-
* @return name of a property converted to system environment variable name.
224-
*/
225-
public static String propertyNameToEnvVarName(String propName) {
226-
return propName.replace(".", "_").replace("-", "_").toUpperCase();
227-
}
228-
229215
/**
230216
* Will merge defined values into placeholders like ${placeholder}
231217
*/
@@ -346,21 +332,18 @@ public static Property getAsProperty(String key) {
346332

347333
/**
348334
* Returns property value for a key.
349-
* <br/>
350-
*
351-
* If this method does not find a property defined in the property files, it converts the property name to
352-
* environment variable name {@link #propertyNameToEnvVarName} and falls through
353-
* to a corresponding environment variable value.
335+
* If the value is null, it will be sourced from the system environment
336+
* variables.
354337
*
355-
* @param propertyName name of a property.
356-
* @return value for this property, <code>null</code> if not found.
338+
* @param key key of property.
339+
* @return value for this key, <code>null</code> if not found.
357340
*/
358-
public static String getProperty(String propertyName) {
341+
public static String getProperty(String key) {
359342
if (!isInited()) {
360343
init();
361344
}
362-
Property p = props.get(propertyName);
363-
return p == null ? System.getenv(propertyNameToEnvVarName(propertyName)) : p.getValue();
345+
Property p = props.get(key);
346+
return p == null ? System.getenv(key) : p.getValue();
364347
}
365348

366349

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy