Stefan Sielaff created WW-5437:
----------------------------------

             Summary: EnvsValueSubstitutor ignores Environment variables if 
default value is present
                 Key: WW-5437
                 URL: https://issues.apache.org/jira/browse/WW-5437
             Project: Struts 2
          Issue Type: Bug
          Components: XML Configuration
    Affects Versions: 6.4.0
            Reporter: Stefan Sielaff


According to the documentation at 
[https://struts.apache.org/core-developers/constant-configuration] it should be 
possible to use both system and environment variables in the constants section. 
Currently environment variables are ignored if a default value is defined.

The sysStrSubstitutor has a less specific prefix which also includes and 
replaces those, which should be passed to the envStrSubstitutor later.

Given
{{<constant name="struts.devMode" value="${env.STRUTS_DEV_MODE:false}"/>}}
and System.getenv('STRUTS_DEV_MODE') is "true"

The code:
String substituted = sysStrSubstitutor.replace(value);
return envStrSubstitutor.replace(substituted);{{}}
The sysStrSubstitutor checks, if there is a system property with the key 
"env.STRUTS_DEV_MODE" which is unset. It then replaces the expression with its 
default. substituted is "false" now. Afterwards the envStrSubstitutor doesn't 
find any expression to substitute, because the string is "false".



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to