arvindKandpal-ksolves commented on code in PR #11941:
URL: https://github.com/apache/nifi/pull/11941#discussion_r4612591664


##########
nifi-bootstrap/src/test/java/org/apache/nifi/bootstrap/command/StopBootstrapCommandTest.java:
##########
@@ -84,4 +84,19 @@ void testRunDestroyFailed() {
 
         assertEquals(CommandStatus.ERROR, commandStatus);
     }
+
+    @Test
+    void testRunDestroyForciblyCompleted() {
+        
when(processHandleProvider.findApplicationProcessHandle()).thenReturn(Optional.of(applicationProcessHandle));
+        when(applicationProcessHandle.destroy()).thenReturn(true);
+        when(applicationProcessHandle.destroyForcibly()).thenReturn(true);

Review Comment:
   nit: configurationProvider.getGracefulShutdownTimeout() is not stubbed here, 
so it returns null and the NullPointerException inside onDestroyCompleted() is 
what leads to destroyForcibly(). Stubbing it, for example 
when(configurationProvider.getGracefulShutdownTimeout()).thenReturn(Duration.ofSeconds(1)),
 would make this test follow the real timeout path. It also needs the 
java.time.Duration import.
   
   I ran the test without the main change and it fails with expected SUCCESS 
but was ERROR, and passes with the fix.
   
   



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

Reply via email to