slfan1989 commented on PR #1347:
URL: https://github.com/apache/ratis/pull/1347#issuecomment-3900511630

   > @slfan1989 , thanks for the update!
   > 
   > For simplicity, if there is an exception, let's just warn it but not throw 
it. Then, we may try-catch each call. What do you think?
   > 
   > ```java
   >   @Override
   >   public void closeImpl() {
   >     for (Server server : servers.values()) {
   >       server.shutdownNow();
   >     }
   >     boolean interrupted = false;
   >     for (Map.Entry<String, Server> server : servers.entrySet()) {
   >       try {
   >         server.getValue().awaitTermination();
   >         LOG.info("{}: Shutdown {} successfully", getId(), server.getKey());
   >       } catch (InterruptedException e) {
   >         Thread.currentThread().interrupt();
   >         LOG.warn("{}: Interrupted shutdown {}", getId(), server.getKey());
   >         interrupted = true;
   >         break;
   >       }
   >     }
   > 
   >     try {
   >       serverInterceptor.close();
   >     } catch (Exception e) {
   >       LOG.warn("{}: Failed to unregister metrics", getId(), e);
   >     }
   > 
   >     if (interrupted) {
   >       executor.shutdown();  // shutdown but not wait
   >     } else {
   >       ConcurrentUtils.shutdownAndWait(executor);
   >     }
   > 
   >     try {
   >       super.closeImpl();
   >     } catch (IOException e) {
   >       LOG.warn("{}: Failed to close proxies", getId(), e);
   >     }
   >   }
   > ```
   
   @szetszwo Thank you very much for reviewing the code! I agree with your 
suggestions and have updated and optimized the code based on your feedback.


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