Copilot commented on code in PR #5399:
URL: https://github.com/apache/solr/pull/5399#discussion_r4719606115


##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -1619,16 +1624,19 @@ Map<String, Object> startSolr(
     startCmd.addArguments(command.subList(1, 
command.size()).toArray(String[]::new), false);
 
     if (isWindows) {
-      // On Windows, the execution doesn't return, so we have to execute async
-      // and when calling the script, it seems to be inheriting the 
environment that launched this
-      // app, so we have to prune out env vars that may cause issues
+      // On Windows, the execution doesn't return, so we have to execute 
async. This process runs
+      // inside bin\solr.cmd, whose SOLR_* variables are its own working 
state, so the node gets
+      // the caller's SOLR_* settings instead, which solr.cmd saved as 
CALLER_SOLR_* on entry.
       Map<String, String> startEnv = new HashMap<>();
       Map<String, String> procEnv = EnvironmentUtils.getProcEnvironment();
       if (procEnv != null) {
         for (Map.Entry<String, String> entry : procEnv.entrySet()) {
           String envVar = entry.getKey();
           String envVarVal = entry.getValue();
-          if (envVarVal != null && !"EXAMPLE".equals(envVar) && 
!envVar.startsWith("SOLR_")) {
+          if (envVarVal == null || "EXAMPLE".equals(envVar)) continue;
+          if (envVar.startsWith(CALLER_ENV_PREFIX + "SOLR_")) {
+            startEnv.put(envVar.substring(CALLER_ENV_PREFIX.length()), 
envVarVal);
+          } else if (!envVar.startsWith("SOLR_") && 
!envVar.startsWith(CALLER_ENV_PREFIX)) {

Review Comment:
   Windows environment names are case-insensitive, but these checks discard a 
saved name such as `CALLER_solr_opts` instead of restoring it. Mixed-case 
`solr_opts` can also bypass pruning, so nodes may lose the caller's setting or 
inherit the launcher's modified value instead. Normalize names for 
classification and restore snapshot keys with canonical casing.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to