Skip to content
Snippets Groups Projects
Commit cb63e803 authored by felmer's avatar felmer
Browse files

SSDM-1366: Fixing bug in ExposablePropertyPlaceholderConfigurer: Resolved...

SSDM-1366: Fixing bug in ExposablePropertyPlaceholderConfigurer: Resolved properties weren't overridden by system properties.

SVN: 33546
parent daef59a8
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ import java.util.Properties; ...@@ -22,6 +22,7 @@ import java.util.Properties;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.Constants;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
...@@ -37,6 +38,9 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC ...@@ -37,6 +38,9 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC
private Properties resolvedProps; private Properties resolvedProps;
private int systemPropertiesMode = PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK;
private static final Constants constants = new Constants(PropertyPlaceholderConfigurer.class);
/** Returns the resolved properties. */ /** Returns the resolved properties. */
public final Properties getResolvedProps() public final Properties getResolvedProps()
{ {
...@@ -46,6 +50,7 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC ...@@ -46,6 +50,7 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC
// //
// PropertyPlaceholderConfigurer // PropertyPlaceholderConfigurer
// //
@Override @Override
protected final String convertPropertyValue(final String originalValue) protected final String convertPropertyValue(final String originalValue)
...@@ -53,6 +58,20 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC ...@@ -53,6 +58,20 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC
// Can handle null value // Can handle null value
return StringUtils.trimWhitespace(originalValue); return StringUtils.trimWhitespace(originalValue);
} }
@Override
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException
{
setSystemPropertiesMode(constants.asNumber(constantName).intValue());
}
@Override
public void setSystemPropertiesMode(int systemPropertiesMode)
{
this.systemPropertiesMode = systemPropertiesMode;
super.setSystemPropertiesMode(systemPropertiesMode);
}
@Override @Override
protected final void processProperties( protected final void processProperties(
...@@ -64,8 +83,13 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC ...@@ -64,8 +83,13 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC
for (final Object key : props.keySet()) for (final Object key : props.keySet())
{ {
final String keyStr = key.toString(); final String keyStr = key.toString();
resolvedProps.setProperty(keyStr, parseStringValue(props.getProperty(keyStr), props, resolvedProps.setProperty(keyStr, getResolvedProperty(props, keyStr));
new HashSet<Object>()));
} }
} }
@SuppressWarnings("deprecation")
private String getResolvedProperty(final Properties props, final String key)
{
return parseStringValue(resolvePlaceholder(key, props, systemPropertiesMode), props, new HashSet<Object>());
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment