You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (JIRA)" <ji...@apache.org> on 2015/04/06 19:29:22 UTC

[jira] [Closed] (LANG-1055) StrSubstitutor.replaceSystemProperties does not work consistently

     [ https://issues.apache.org/jira/browse/LANG-1055?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter closed LANG-1055.
---------------------------------

> StrSubstitutor.replaceSystemProperties does not work consistently
> -----------------------------------------------------------------
>
>                 Key: LANG-1055
>                 URL: https://issues.apache.org/jira/browse/LANG-1055
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.text.*
>    Affects Versions: 3.3.2
>         Environment: Windows 7, Java 7
>            Reporter: Phil Dicke
>            Assignee: Benedikt Ritter
>             Fix For: 3.4
>
>
> StrSubsitutor caches a references to SystemProperties statically on first class references.  This does not work properly with System.setProperties().  For example the following code:
> {code}
> package test.utilities;
> import java.util.Properties;
> import org.apache.commons.lang.text.StrSubstitutor;
> public class TestStrSubstitutor {
>     public static void main(String[] args) {
>         System.out.println(StrSubstitutor.replaceSystemProperties("os.name=${os.name}"));
>         Properties testProps = new Properties();
>         testProps.put("test_key",  "test_value");
>         testProps.putAll(System.getProperties());
>         System.setProperties(testProps);
>         System.out.println(StrSubstitutor.replace("test_key=${test_key}", System.getProperties()));
>         System.out.println(StrSubstitutor.replaceSystemProperties("test_key=${test_key}"));
>     }
> }
> {code}
> produces the following output:
> {code}
> os.name=Windows 7
> test_key=test_value
> test_key=${test_key}
> {code}
> The code linked here shows the static caching of the System Properties reference: http://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/text/StrLookup.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)