Oshi: Windows: OSProcess.getCommandLine() almost always blank

Created on 21 Jun 2018  路  3Comments  路  Source: oshi/oshi

It looks like this is an issue with the caching logic at WindowsOperatingSystem.java:385 and WindowsOperatingSystem.java:486. I'll investigate a bit more.

confirmed bug

All 3 comments

I've cloned this repro and added the below test to the OperatingSystemTest. It fails every time for me on Windows.

    @Test
    public void testGetCommandLine() {
        int processesWithNonEmptyCmdLine = 0;

        for (OSProcess process : new SystemInfo().getOperatingSystem().getProcesses(0, null)) {
            if (!process.getCommandLine().trim().isEmpty()) {
                processesWithNonEmptyCmdLine++;
            }
        }

        assertTrue(processesWithNonEmptyCmdLine >= 1);
    }

PR up: #527

Thanks for the fix! I won't even pretend to know what I was thinking when I wrote that... I think I re-used a map that had been populated a different way and neglected to check/change the logic. Or was sleep deprived.

Gold star for the added unit test.

Was this page helpful?
0 / 5 - 0 ratings