Use JNA/WMI instead of PowerShell to list Windows processes - #4718
Draft
janhoy wants to merge 2 commits into
Draft
Use JNA/WMI instead of PowerShell to list Windows processes#4718janhoy wants to merge 2 commits into
janhoy wants to merge 2 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
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.