Summary
Maven tests pass locally on Windows with JDK 17 but fail in GitHub Actions on Linux with JDK 17. Two tests fail with Mockito-related errors:
WinRMCommandExecutorTest.testExecute — NullPointerException: Cannot invoke "[Ljava.lang.Class;.clone()" because "parameterTypes" is null
WinRMWqlExecutorTest.testExecute — InvalidUseOfMatchersException (cascading failure)
This is not a Java version mismatch. CI and local both use JDK 17.
Root cause
WinRMInvocationHandlerTest uses a static mock of java.lang.reflect.Method:
private static final Method METHOD = mock(Method.class);
Mocking core JDK reflection types breaks Mockito's own reflection internals (mockito#2026). After this mock is created, later stubbing of methods such as executeCommand(...) can fail with a NullPointerException on Method.getParameterTypes().
The InvalidUseOfMatchersException in WinRMWqlExecutorTest is a secondary effect of polluted Mockito matcher state, not a separate bug in that test.
Why it passes locally but fails in CI
Surefire test execution order is filesystem-dependent:
| Environment |
Typical order |
Result |
| Windows local |
WinRMCommandExecutorTest runs before WinRMInvocationHandlerTest |
Pass |
| Linux CI |
WinRMInvocationHandlerTest runs first, corrupts Mockito, then others fail |
Fail |
Proposed fix
-
WinRMInvocationHandlerTest — Remove mock(Method.class). Use a real WinRMWebService.receive Method and stub WIN_RM_WS.receive(...) instead of Method.invoke(...).
-
WinRMCommandExecutorTest — In the SMB/file-copy path, mock WinRMService (concrete class) instead of the WindowsRemoteExecutor interface, and use eq(UTF_8) instead of any(Charset.class) for consistency with the other test branch.
Acceptance criteria
References
Summary
Maven tests pass locally on Windows with JDK 17 but fail in GitHub Actions on Linux with JDK 17. Two tests fail with Mockito-related errors:
WinRMCommandExecutorTest.testExecute—NullPointerException: Cannot invoke "[Ljava.lang.Class;.clone()" because "parameterTypes" is nullWinRMWqlExecutorTest.testExecute—InvalidUseOfMatchersException(cascading failure)This is not a Java version mismatch. CI and local both use JDK 17.
Root cause
WinRMInvocationHandlerTestuses a static mock ofjava.lang.reflect.Method:Mocking core JDK reflection types breaks Mockito's own reflection internals (mockito#2026). After this mock is created, later stubbing of methods such as
executeCommand(...)can fail with aNullPointerExceptiononMethod.getParameterTypes().The
InvalidUseOfMatchersExceptioninWinRMWqlExecutorTestis a secondary effect of polluted Mockito matcher state, not a separate bug in that test.Why it passes locally but fails in CI
Surefire test execution order is filesystem-dependent:
WinRMCommandExecutorTestruns beforeWinRMInvocationHandlerTestWinRMInvocationHandlerTestruns first, corrupts Mockito, then others failProposed fix
WinRMInvocationHandlerTest— Removemock(Method.class). Use a realWinRMWebService.receiveMethodand stubWIN_RM_WS.receive(...)instead ofMethod.invoke(...).WinRMCommandExecutorTest— In the SMB/file-copy path, mockWinRMService(concrete class) instead of theWindowsRemoteExecutorinterface, and useeq(UTF_8)instead ofany(Charset.class)for consistency with the other test branch.Acceptance criteria
mvn testpasses on Linux CI with JDK 17-Dtest=WinRMInvocationHandlerTest,WinRMCommandExecutorTest,WinRMWqlExecutorTest)java.lang.reflect.Methodor other core JDK reflection types in testsReferences
WinRMInvocationHandlerTest,WinRMCommandExecutorTest,WinRMWqlExecutorTest