slfan1989 commented on code in PR #1571:
URL: https://github.com/apache/ratis/pull/1571#discussion_r3888638226


##########
ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java:
##########
@@ -507,86 +513,119 @@ void runTestBootstrapReconf(int numNewPeer, boolean 
startNewPeer, CLUSTER cluste
    * retrying.
    */
   @Test
-  @Flaky("RATIS-2251")
+  @Timeout(120)
   public void testKillLeaderDuringReconf() throws Exception {
     // originally 3 peers
     runWithNewCluster(3, this::runTestKillLeaderDuringReconf);
   }
 
+  /**
+   * Checks whether the server is bootstrapping the given peer.
+   *
+   * @param server the server division to check
+   * @param peerId the ID of the peer to check
+   * @return true if the peer is being bootstrapped in the leader staging 
state; otherwise, false
+   */
+  private static boolean isBootstrappingPeer(RaftServer.Division server, 
RaftPeerId peerId) {
+    return ((RaftServerImpl) server).getRole().getLeaderState()
+        .filter(LeaderStateImpl::inStagingState)
+        .map(state -> state.isBootStrappingPeer(peerId))
+        .orElse(false);
+  }
+
   void runTestKillLeaderDuringReconf(CLUSTER cluster) throws Exception {
-    final AtomicBoolean clientRunning = new AtomicBoolean(true);
-    Thread clientThread = null;
+    final ExecutorService executor = ConcurrentUtils.newSingleThreadExecutor(

Review Comment:
   Replace the manually managed client thread, control flag, and 
`CompletableFuture` with an `ExecutorService` and `Future`.  
   
   This simplifies the asynchronous workflow and provides explicit result 
handling, exception propagation, cancellation, timeout control, and 
deterministic cleanup.



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