You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/04/30 14:38:05 UTC

[tomcat] branch master updated: 64398: Change default value separator for property replacement

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

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 90b8ff2  64398: Change default value separator for property replacement
90b8ff2 is described below

commit 90b8ff2f330973bbe54dbbe3d702b3111bb781fc
Author: remm <re...@apache.org>
AuthorDate: Thu Apr 30 16:37:52 2020 +0200

    64398: Change default value separator for property replacement
    
    Due to conflicts, the syntax is now ${name:-default}.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java     | 4 ++--
 test/org/apache/tomcat/util/TestIntrospectionUtils.java | 8 ++++----
 webapps/docs/changelog.xml                              | 5 +++++
 webapps/docs/config/systemprops.xml                     | 2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java b/java/org/apache/tomcat/util/IntrospectionUtils.java
index aa2f40c..eef8980 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -268,9 +268,9 @@ public final class IntrospectionUtils {
                 String v = getProperty(n, staticProp, dynamicProp, classLoader);
                 if (v == null) {
                     // {name:default}
-                    int col = n.indexOf(':');
+                    int col = n.indexOf(":-");
                     if (col != -1) {
-                        String dV = n.substring(col+1);
+                        String dV = n.substring(col + 2);
                         n = n.substring(0, col);
                         v = getProperty(n, staticProp, dynamicProp, classLoader);
                         if (v == null) {
diff --git a/test/org/apache/tomcat/util/TestIntrospectionUtils.java b/test/org/apache/tomcat/util/TestIntrospectionUtils.java
index ef27174..ed9fe39 100644
--- a/test/org/apache/tomcat/util/TestIntrospectionUtils.java
+++ b/test/org/apache/tomcat/util/TestIntrospectionUtils.java
@@ -130,16 +130,16 @@ public class TestIntrospectionUtils {
         Assert.assertEquals("abcvalue1xyz", IntrospectionUtils.replaceProperties(
                 "abc${normal}xyz", properties, null, null));
 
-        properties.setProperty("prop_with:colon", "value2");
+        properties.setProperty("prop_with:-colon", "value2");
         Assert.assertEquals("value2", IntrospectionUtils.replaceProperties(
-                "${prop_with:colon}", properties, null, null));
+                "${prop_with:-colon}", properties, null, null));
 
         Assert.assertEquals("value1", IntrospectionUtils.replaceProperties(
-                "${normal:default}", properties, null, null));
+                "${normal:-default}", properties, null, null));
 
         properties.remove("normal");
         Assert.assertEquals("default", IntrospectionUtils.replaceProperties(
-                "${normal:default}", properties, null, null));
+                "${normal:-default}", properties, null, null));
 
         Assert.assertEquals("abc${normal}xyz", IntrospectionUtils.replaceProperties(
                 "abc${normal}xyz", properties, null, null));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e851a9a..b58f06c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -109,6 +109,11 @@
       <update>
         Remove reason phrase on WebDAV Multi-Status (207) response. (michaelo)
       </update>
+      <fix>
+        <bug>64398</bug>: Change default value separator for property
+        replacement to <code>:-</code> due to possible conflicts. The
+        syntax is now <code>${name:-default}</code>. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">
diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml
index 0b00c60..afc7208 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -45,7 +45,7 @@
          <code>org.apache.tomcat.util.IntrospectionUtils.PropertySource</code>.
          Required to have a public constructor with no arguments.</p>
       <p>Use this to add a property source, that will be invoked when
-         <code>${parameter:default-value}</code> denoted parameters (with
+         <code>${parameter:-default-value}</code> denoted parameters (with
          optional default values) are found in the XML files that Tomcat
          parses.</p>
       <p>Property replacement from the specified property source on the JVM


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org