#1338 - Regression since 11.12.1 - resolve expressions in Properties given to serverConfig.loadFromProperties()

This commit is contained in:
Rob Bygrave committed 2018-03-07 16:43:42 +13:00
1 parent 47e8d27212
commit baa7242939
4 files changed
+53 -5

No files matched your search

@@ -2642,7 +2642,8 @@ public class ServerConfig {
* Load settings from ebean.properties.
*/
public void loadFromProperties() {
loadFromProperties(PropertiesLoader.load());
this.properties = PropertiesLoader.load();
configureFromProperties();
}
/**
@@ -2650,7 +2651,14 @@ public class ServerConfig {
*/
public void loadFromProperties(Properties properties) {
// keep the properties used for configuration so that these are available for plugins
this.properties = properties;
this.properties = PropertiesLoader.eval(properties);
configureFromProperties();
}
/**
* Load the settings from the given properties
*/
private void configureFromProperties() {
autoConfiguration();
PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties);
loadSettings(p);
@@ -1,5 +1,6 @@
package io.ebean.config.properties;
import java.util.Enumeration;
import java.util.Properties;
/**
@@ -66,4 +67,19 @@ public class PropertiesLoader {
properties.setProperty(key, value);
}
/**
* Return a copy of the properties with 'eval' run on all the values.
* This resolves expressions like ${HOME} etc.
*/
public static Properties eval(Properties properties) {
Properties evalCopy = new Properties();
Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
String name = (String)names.nextElement();
String value = PropertyEval.eval(properties.getProperty(name));
evalCopy.setProperty(name, value);
}
return evalCopy;
}
}