[ 
https://issues.apache.org/jira/browse/JSPWIKI-1319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140307#comment-18140307
 ] 

ASF subversion and git services commented on JSPWIKI-1319:
----------------------------------------------------------

Commit afe2f530e9b726572412f4f29bf593c8bf790b19 in jspwiki's branch 
refs/heads/master from Arturo Bernal
[ https://gitbox.apache.org/repos/asf?p=jspwiki.git;h=afe2f530e ]

JSPWIKI-1319 Read the jspwiki.* system properties with their real keys


> PropertyReader ignores jspwiki.* system properties passed with -D
> -----------------------------------------------------------------
>
>                 Key: JSPWIKI-1319
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-1319
>             Project: JSPWiki
>          Issue Type: Bug
>            Reporter: Arturo Bernal
>            Priority: Major
>              Labels: pull-request-available
>
> PropertyReader.loadWebAppProps() ignores every jspwiki.* Java system property 
> passed with -D.
> The system properties are collected with Collectors.toMap( Object::toString, 
> Object::toString ) over System.getProperties().entrySet(). Object::toString 
> on a Map.Entry returns "key=value", so both the key and the value of the 
> resulting map are "key=value". collectPropertiesFrom() then keeps the entry 
> because the string starts with "jspwiki", but the property is stored under 
> the key "jspwiki.foo=bar" and never under "jspwiki.foo".
> Measured on master with a unit test: System.setProperty( 
> "jspwiki.test.systemProperty", "fromSystem" ), then 
> PropertyReader.loadWebAppProps( mock( ServletContext.class ) ); 
> props.getProperty( "jspwiki.test.systemProperty" ) returns null (expected 
> "fromSystem"). The same effect was seen in a running instance (Tomcat 10.1, 
> JDK 17) with a jspwiki.* property passed with -D: the properties contained 
> the key "jspwiki.<name>=<value>" and the code that reads the property did not 
> see the value. The same property set in a custom properties file or as an 
> environment variable works.
> Using System.getProperties().stringPropertyNames() with System::getProperty 
> as the value fixes it; the test above then passes, as do the 8 tests of 
> PropertyReaderTest.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to