bamaer commented on code in PR #9494:
URL: https://github.com/apache/hop/pull/9494#discussion_r4577281804
##########
core/src/main/java/org/apache/hop/core/variables/Variables.java:
##########
@@ -122,19 +122,19 @@ public void initializeFrom(IVariables parent) {
getProperties().putAll(System.getenv());
}
- // Clone the system properties to avoid ConcurrentModificationException
while iterating
- // and then add all of them to properties variable.
+ List<DescribedVariable> describedVariables =
HopConfig.getInstance().getDescribedVariables();
+ for (DescribedVariable describedVariable : describedVariables) {
+ getProperties().put(describedVariable.getName(),
describedVariable.getValue());
+ }
+
+ // Clone the system properties to avoid ConcurrentModificationException
while iterating.
+ // Apply them after hop-config defaults so explicit launcher options keep
their precedence.
//
Set<String> systemPropertiesNames =
System.getProperties().stringPropertyNames();
for (String key : systemPropertiesNames) {
getProperties().put(key, System.getProperties().getProperty(key));
}
Review Comment:
**Blocker:** system properties aren't only launcher options. At startup,
`HopEnvironment.init()` copies every hop-config variable that wasn't given with
`-D` into `System.setProperty` (`HopEnvironment.java:196-203`). With this
order, that startup copy now wins over hop-config for the rest of the session.
In Hop GUI: change a variable in Configuration → Variables, save, then
reload the project (#2293) or switch projects. The fresh
`Variables.getADefaultVariableSpace()` gets the old startup value instead of
the saved one. Test: hop-config `/data/old`, same value copied to the system
property, hop-config edited to `/data/new`, then `new
Variables().initializeFrom(null)` gives `/data/old` on this PR and `/data/new`
on main.
Suggested fix: keep main's order and skip a hop-config value only when the
name came from the command line. For example, have `HopEnvironment` record the
names it copies, and in `initializeFrom`:
```java
if (System.getProperties().containsKey(name) &&
!copiedFromConfig.contains(name)) {
continue; // -D wins
}
```
With that, both new tests and the stale-value case pass.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]