linlinnn commented on a change in pull request #10599:
URL: https://github.com/apache/pulsar/pull/10599#discussion_r632976110



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/GracefulExecutorServicesShutdownTest.java
##########
@@ -120,25 +121,28 @@ public void shouldWaitForExecutorToTerminate() throws 
ExecutionException, Interr
 
 
     @Test
-    public void shouldTerminateWhenFutureIsCancelled() throws 
InterruptedException {
+    public void shouldTerminateWhenFutureIsCancelled() throws 
InterruptedException, ExecutionException {
         // given
         GracefulExecutorServicesShutdown shutdown = 
GracefulExecutorServicesShutdown.initiate();
         shutdown.timeout(Duration.ofMillis(15000));
         ExecutorService executorService = mock(ExecutorService.class);
         when(executorService.isShutdown()).thenReturn(true);
         AtomicBoolean terminated = new AtomicBoolean();
-        AtomicBoolean awaitTerminationInterrupted = new AtomicBoolean();
+        CompletableFuture<Boolean> awaitTerminationInterrupted = new 
CompletableFuture<>();
         when(executorService.isTerminated()).thenAnswer(invocation -> 
terminated.get());
+        CountDownLatch awaitingTerminationEntered = new CountDownLatch(1);
         when(executorService.awaitTermination(anyLong(), 
any())).thenAnswer(invocation  -> {
             long timeout = invocation.getArgument(0);
             TimeUnit unit = invocation.getArgument(1);
+            awaitingTerminationEntered.countDown();

Review comment:
       1. awaitingTerminationEntered.countDown() and if the thread do not run 
into try block.
   2. future.cancel(false);
   then awaitTerminationInterrupted maybe never complete.
   




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to