Use JNA/WMI instead of PowerShell to list Windows processes - #4718
Draft
janhoy wants to merge 7 commits into
Draft
Use JNA/WMI instead of PowerShell to list Windows processes#4718janhoy wants to merge 7 commits into
janhoy wants to merge 7 commits into
Conversation
SolrProcessManager previously spawned a powershell.exe process running Get-CimInstance to obtain command lines of Java processes on Windows. Replace this with a WMI (Win32_Process) query via JNA, avoiding an external process spawn and the dependency on PowerShell being present. - Add net.java.dev.jna:jna-platform dependency to solr-core - Drop the PowerShell JSON parsing helper and its test - Remove the broad "<<ALL FILES>>" execute grant from the test security policy (only needed to exec powershell) and add the JNA native-library load / jna.* property-read permissions instead
chan-dx
reviewed
Aug 13, 2026
…line # Conflicts: # solr/core/gradle.lockfile # solr/cross-dc-manager/gradle.lockfile # solr/modules/analysis-extras/gradle.lockfile # solr/modules/cross-dc/gradle.lockfile # solr/modules/jwt-auth/gradle.lockfile # solr/modules/ltr/gradle.lockfile # solr/modules/s3-repository/gradle.lockfile # solr/solrj/gradle.lockfile # solr/webapp/gradle.lockfile
Filter java processes with 'WHERE Name LIKE %java%' in the WMI query instead of checking the process name in the loop. WMI LIKE is case-insensitive, matching the previous behaviour. Thanks to @chan-dx for the suggestion and for validating it on Windows.
The initial lockfile regeneration (resolveAndLockAll only) omitted the compileClasspathCopy/runtimeClasspathCopy/testCompileClasspathCopy/ testRuntimeClasspathCopy configurations that the jar-checks 'collectJarInfos' task resolves, causing CI to fail with 'Resolved net.java.dev.jna:jna(-platform) which is not part of the dependency lock state'. Regenerated with 'resolveAndLockAll collectJarInfos --write-locks' so the *Copy configurations are included.
SOLR-15465 (apache#4793) removed jna-LICENSE-ASL.txt and jna-NOTICE.txt on main since jna was not shipped there. This PR adds jna-platform to solr-core, making jna a shipped runtime dependency, so its LICENSE/NOTICE are required again. The merge dropped them; restore both.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Windows,
SolrProcessManager(used by thebin/solr statusCLI) discovers running Solr processes by reading each Java process's command line. SinceProcessHandledoes not expose command lines on Windows, it previously spawnedpowershell.exerunningGet-CimInstance -ClassName Win32_Process ... | ConvertTo-Jsonand parsed the JSON.This PR replaces that with a direct WMI (
Win32_Process) query via JNA (jna-platform), so no external process is spawned and PowerShell no longer needs to be present/enabled.Changes
net.java.dev.jna:jna-platformtosolr-core.commandLinesWindows()to useCoInitializeEx→WmiQuery→CoUninitialize; drop the PowerShell JSON parsing helper and its unit test.<<ALL FILES>>executegrant (only needed to exec powershell) and add the JNA native-library load /jna.*property-read permissions instead.Notes
Constants.WINDOWS); Linux/macOS behaviour is unchanged and all static checks +SolrProcessManagerTestpass. The live WMI query has not been exercised on real Windows yet.Draft pending validation on a Windows runner.