diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java index c9d39f3bf5f..3671c5e51c9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.core.Constants; +import org.springframework.core.env.AbstractEnvironment; import org.springframework.util.PropertyPlaceholderHelper; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; import org.springframework.util.StringValueResolver; @@ -82,7 +83,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK; - private boolean searchSystemEnvironment = true; + private boolean searchSystemEnvironment = + !"true".equalsIgnoreCase(System.getProperty(AbstractEnvironment.IGNORE_GETENV_PROPERTY_NAME)); /** diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index 24188c9fdd6..aec12871852 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -52,6 +52,18 @@ import static org.springframework.util.StringUtils.*; */ public abstract class AbstractEnvironment implements ConfigurableEnvironment { + /** + * System property that instructs Spring to ignore system environment variables, + * i.e. to never attempt to retrieve such a variable via {@link System#getenv()}. + *
The default is "false", falling back to system environment variable checks if a + * Spring environment property (e.g. a placeholder in a configuration String) isn't + * resolvable otherwise. Consider switching this flag to "true" if you experience + * log warnings from {@code getenv} calls coming from Spring, e.g. on WebSphere + * with strict SecurityManager settings and AccessControlExceptions warnings. + */ + public static final String IGNORE_GETENV_PROPERTY_NAME = "spring.getenv.ignore"; + + /** * Name of property to set to specify active profiles: {@value}. Value may be comma * delimited. @@ -168,8 +180,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { * {@code remove}, or {@code replace} methods exposed by {@link MutablePropertySources} * in order to create the exact arrangement of property sources desired. * - *
The base implementation in {@link AbstractEnvironment#customizePropertySources} - * registers no property sources. + *
The base implementation registers no property sources. * *
Note that clients of any {@link ConfigurableEnvironment} may further customize
* property sources via the {@link #getPropertySources()} accessor, typically within
@@ -229,7 +240,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
*/
protected Set