Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5437

EnvsValueSubstitutor ignores Environment variables if default value is present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 6.4.0
    • 6.6.0
    • XML Configuration
    • None

    Description

      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

      System.getenv('STRUTS_DEV_MODE') is "true"

      <constant name="struts.devMode" value="${env.STRUTS_DEV_MODE:false}"/>
      

      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".

      Attachments

        Activity

          People

            Unassigned Unassigned
            stefansielaff Stefan Sielaff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m