[jira] [Commented] (LANG-1055) StrSubstitutor.replaceSystemProperties does not work constistently

2015-01-21 Thread Jonathan Baker (JIRA)

[ 
https://issues.apache.org/jira/browse/LANG-1055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14286057#comment-14286057
 ] 

Jonathan Baker commented on LANG-1055:
--

Not sure if this is correct, or if it addresses Phil's concerns, but the 
following is an implementation that 1) does not use a singleton, and 2) allows 
each instance to have their own snap-shop of the system properties:

https://github.com/apache/commons-lang/pull/43

Thanks in advance for your time.

 StrSubstitutor.replaceSystemProperties does not work constistently
 --

 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

 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)


[jira] [Commented] (LANG-1055) StrSubstitutor.replaceSystemProperties does not work constistently

2015-01-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/LANG-1055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14286055#comment-14286055
 ] 

ASF GitHub Bot commented on LANG-1055:
--

GitHub user j--baker opened a pull request:

https://github.com/apache/commons-lang/pull/43

LANG-1055: StrLookup.systemPropertiesLookup() not singleton.

- Assuming StrLookup.systemPropertiesLookup() should not be a singleton.
- Assuming each lookup should have its own snap-shot of the system 
properties.

Please review the proposed changes.
Thank you!

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/j--baker/commons-lang LANG-1055

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/43.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #43


commit f4d574872bdd488032b296faece7921737518c3a
Author: j--baker j--ba...@users.noreply.github.com
Date:   2015-01-21T18:45:11Z

LANG-1055: Change StrLookup.systemPropertiesLookup() to return a new 
instance with its own copy of the current system properties.




 StrSubstitutor.replaceSystemProperties does not work constistently
 --

 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

 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)