Consistent ordered list access and lazy streaming for ObjectProvider
Includes fallback match for collection/map dependency if qualified. Issue: SPR-17272 Issue: SPR-17197
This commit is contained in:
@@ -382,6 +382,32 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
return this.propertySources;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public Map<String, Object> getSystemProperties() {
|
||||
try {
|
||||
return (Map) System.getProperties();
|
||||
}
|
||||
catch (AccessControlException ex) {
|
||||
return (Map) new ReadOnlySystemAttributesMap() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getSystemAttribute(String attributeName) {
|
||||
try {
|
||||
return System.getProperty(attributeName);
|
||||
}
|
||||
catch (AccessControlException ex) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Caught AccessControlException when accessing system property '" +
|
||||
attributeName + "'; its value will be returned [null]. Reason: " + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public Map<String, Object> getSystemEnvironment() {
|
||||
@@ -426,32 +452,6 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public Map<String, Object> getSystemProperties() {
|
||||
try {
|
||||
return (Map) System.getProperties();
|
||||
}
|
||||
catch (AccessControlException ex) {
|
||||
return (Map) new ReadOnlySystemAttributesMap() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected String getSystemAttribute(String attributeName) {
|
||||
try {
|
||||
return System.getProperty(attributeName);
|
||||
}
|
||||
catch (AccessControlException ex) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Caught AccessControlException when accessing system property '" +
|
||||
attributeName + "'; its value will be returned [null]. Reason: " + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(ConfigurableEnvironment parent) {
|
||||
for (PropertySource<?> ps : parent.getPropertySources()) {
|
||||
|
||||
@@ -118,21 +118,6 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
|
||||
*/
|
||||
MutablePropertySources getPropertySources();
|
||||
|
||||
/**
|
||||
* Return the value of {@link System#getenv()} if allowed by the current
|
||||
* {@link SecurityManager}, otherwise return a map implementation that will attempt
|
||||
* to access individual keys using calls to {@link System#getenv(String)}.
|
||||
* <p>Note that most {@link Environment} implementations will include this system
|
||||
* environment map as a default {@link PropertySource} to be searched. Therefore, it
|
||||
* is recommended that this method not be used directly unless bypassing other
|
||||
* property sources is expressly intended.
|
||||
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
|
||||
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
|
||||
* to a property, {@code null} will be returned and an INFO-level log message will be
|
||||
* issued noting the exception.
|
||||
*/
|
||||
Map<String, Object> getSystemEnvironment();
|
||||
|
||||
/**
|
||||
* Return the value of {@link System#getProperties()} if allowed by the current
|
||||
* {@link SecurityManager}, otherwise return a map implementation that will attempt
|
||||
@@ -148,6 +133,21 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
|
||||
*/
|
||||
Map<String, Object> getSystemProperties();
|
||||
|
||||
/**
|
||||
* Return the value of {@link System#getenv()} if allowed by the current
|
||||
* {@link SecurityManager}, otherwise return a map implementation that will attempt
|
||||
* to access individual keys using calls to {@link System#getenv(String)}.
|
||||
* <p>Note that most {@link Environment} implementations will include this system
|
||||
* environment map as a default {@link PropertySource} to be searched. Therefore, it
|
||||
* is recommended that this method not be used directly unless bypassing other
|
||||
* property sources is expressly intended.
|
||||
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
|
||||
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
|
||||
* to a property, {@code null} will be returned and an INFO-level log message will be
|
||||
* issued noting the exception.
|
||||
*/
|
||||
Map<String, Object> getSystemEnvironment();
|
||||
|
||||
/**
|
||||
* Append the given parent environment's active profiles, default profiles and
|
||||
* property sources to this (child) environment's respective collections of each.
|
||||
|
||||
Reference in New Issue
Block a user