slfan1989 opened a new pull request, #1347:
URL: https://github.com/apache/ratis/pull/1347

   ## What changes were proposed in this pull request?
   
   Fixed a resource cleanup bug in `GrpcServicesImpl.closeImpl()` method where:
   
   1. **Multiple invocations bug**: `super.closeImpl()` was called inside the 
server shutdown loop, causing the parent class cleanup logic to be executed 
multiple times (once per server entry in the map)
   
   2. **Resource leak risk**: If any server shutdown fails with an exception, 
`super.closeImpl()`, `serverInterceptor.close()`, and 
`ConcurrentUtils.shutdownAndWait(executor)` would not be executed, leading to 
resource leaks
   
   **Changes made**:
   - Wrapped the server shutdown loop in a try-finally block
   - Moved `super.closeImpl()` to the finally block to ensure it executes 
exactly once
   - Ensured proper cleanup order: child resources → parent resources → 
remaining resources
   
   ## What is the link to the Apache JIRA
   
   RATIS-2406. Fix resource cleanup bug in GrpcServicesImpl.closeImpl() method.
   
   ## How was this patch tested?
   
   - Existing unit tests pass


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