You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@struts.apache.org by "lukaszlenart (via GitHub)" <gi...@apache.org> on 2026/10/12 12:13:46 UTC

[PR] WW-5767 Apply value substitution to scoped-constant values [struts]

lukaszlenart opened a new pull request, #2007:
URL: https://github.com/apache/struts/pull/2007

   Fixes [WW-5767](https://issues.apache.org/jira/browse/WW-5767)
   
   ## Summary
   
   `<scoped-constant>` values (added in WW-3476) are now run through the injected `ValueSubstitutor` when the configuration loads, the same way `<constant>` values have been since 2.5.6. `${env.NAME}` and `${system.property}` now resolve instead of being kept as literal text.
   
   ```xml
   <package name="admin" extends="struts-default">
       <scoped-constant name="some.scopable.constant" value="${env.SOME_VALUE}"/>
   </package>
   ```
   
   `registerConstant` and `loadScopedConstants` now call one private helper, `substituteValue`, so the two elements can't drift apart. Substitution still runs once, at load time, and produces a static string. This is not the per-request evaluation that WW-3476 ruled out. `PackageConfig`, the startup validation and `ScopedConstantProvider` are unchanged.
   
   ## Tests
   
   `ScopedConstantsSubstitutionTest` (new, JUnit 4) with a new fixture, `struts-scoped-constants-substitution.xml`:
   - A scoped constant set to `${ww5767.value}` resolves to the system property the test sets, then clears.
   - A literal value is kept as written.
   
   The test loads `struts-default.xml` in Dispatcher order. `loadPackages()` gets its `ValueSubstitutor` from the main container, which in production comes from `struts-beans.xml`. The ticket suggested `XmlConfigurationProviderPackagesTest`, but its `ConfigurationTestBase` container registers no substitutor, so a test there could not see the change.
   
   Before the fix, the test failed with `but was: "${ww5767.value}"`. The existing `XmlConfigurationProviderEnvsSubstitutionTest` still passes after the refactor. The full `core` suite passes: 3447 tests, 0 failures.
   
   ## Follow-up
   
   The struts-site page `core-developers/package-configuration.md` says value substitution is not supported for scoped constants (apache/struts-site#351). That sentence needs updating once this is merged.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5767 Apply value substitution to scoped-constant values [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2007:
URL: https://github.com/apache/struts/pull/2007#issuecomment-6128914518

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2007) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2007&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2007&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=2007&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2007&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2007&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2007)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5767 Apply value substitution to scoped-constant values [struts]

Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart merged PR #2007:
URL: https://github.com/apache/struts/pull/2007


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5767 Apply value substitution to scoped-constant values [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2007:
URL: https://github.com/apache/struts/pull/2007#issuecomment-6125875445

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2007) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [77.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2007&metric=new_coverage&view=list) (required ≥ 80%)  
     
   <!-- sqra:qg_revision=686a6ee8d982b640188d64e48afaeca6ebfe12e93992690cb0f7c112db58262f -->
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2007)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org