janhoy commented on code in PR #4718:
URL: https://github.com/apache/solr/pull/4718#discussion_r4201475591


##########
solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java:
##########
@@ -174,55 +173,45 @@ private static Optional<String> commandLine(ProcessHandle 
ph) {
   }
 
   /**
-   * Gets the command lines of all java processes on Windows using PowerShell.
+   * WMI columns to select from {@code Win32_Process}. The enum constant names 
are used verbatim as
+   * the WQL {@code SELECT} column names (WQL is case-insensitive).
+   */
+  enum ProcessProperty {
+    PROCESSID,
+    COMMANDLINE
+  }
+
+  /**
+   * Gets the command lines of all java processes on Windows by querying WMI 
({@code Win32_Process})
+   * through JNA. This avoids spawning an external PowerShell process.
    *
    * @return a map of process IDs to command lines
    */
   private static Map<Long, String> commandLinesWindows() {
+    COMUtils.checkRC(Ole32.INSTANCE.CoInitializeEx(null, 
Ole32.COINIT_MULTITHREADED));

Review Comment:
   Thanks for the review. In runtime there is always one ProcessManager. 
Perhaps in tests there may be multiple, but still a corner case. Agree we can 
handle this if we get flaky tests. But that would happen on Win CI runners 
only...



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