This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository

commit b58f02a0f88fead8ab5210566a396dae476d9362
Author: Thomas Meyer <>
AuthorDate: Sat Jul 20 22:22:42 2019 +0200

    PropertySource: Add an environment variable based source
    When tomcat runs in an Openshift based container a Secret containing 
    can be map as environment variables (with an additional prefix).
    An webapp containing an embedded context.xml which defines JDBC datasources 
    placeholder variables can be used with this new PropertySource to easily 
    configuration from a Secret or ConfigMap.
 java/org/apache/tomcat/util/digester/ | 15 +++++++++++++++
 webapps/docs/changelog.xml                         |  6 ++++++
 webapps/docs/config/systemprops.xml                |  9 +++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/ 
index 59d59f0..f31518c 100644
--- a/java/org/apache/tomcat/util/digester/
+++ b/java/org/apache/tomcat/util/digester/
@@ -139,6 +139,21 @@ public class Digester extends DefaultHandler2 {
+    public class EnvironmentPropertySource implements 
IntrospectionUtils.PropertySource {
+        @Override
+        public String getProperty(String key) {
+            ClassLoader cl = getClassLoader();
+            if (cl instanceof PermissionCheck) {
+                Permission p = new RuntimePermission("getenv." + key, null);
+                if (!((PermissionCheck) cl).check(p)) {
+                    return null;
+                }
+            }
+            return System.getenv(key);
+        }
+    }
     protected IntrospectionUtils.PropertySource source[] = new 
IntrospectionUtils.PropertySource[] {
             new SystemPropertySource() };
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 75c640c..2cf2b54 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -57,6 +57,12 @@
         Service is embedded directly (i.e. with no Server) in an applciation
         and JNDI is enabled. Patch provided by S. Ali Tokmen. (markt)
+      <add>
+        Add a new <code>PropertySource</code> implementation,
+        <code>EnvironmentPropertySource</code>, that can be used to do property
+        replacement in configuration files with environment variables. Pull
+        request provided by Thomas Meyer. (markt)
+      </add>
   <subsection name="Coyote">
diff --git a/webapps/docs/config/systemprops.xml 
index cb39fb1..5e37c42 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -43,11 +43,16 @@
       <p>Set this to a fully qualified name of a class that implements
          Required to have a public constructor with no arguments.</p>
-      <p>Use this to add a property source, that will be invoked when 
-         denoted parameters are found in the XML files that Tomcat parses.</p>
+      <p>Use this to add a property source, that will be invoked when
+         <code>${parameter}</code> denoted parameters are found in the XML 
+         that Tomcat parses.</p>
       <p>Property replacement from the specified property source on the JVM
          system properties can also be done using the
          <code>REPLACE_SYSTEM_PROPERTIES</code> system property.</p>
+         can be used to replace parameters from the process' environment
+         variables, e.g. injected ConfigMaps or Secret objects in container
+         based systems like OpenShift or Kubernetes.</p>
     <property name="org.apache.tomcat.util.digester. 
       <p>Set this boolean system property to <code>true</code> to cause

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to