xcx1r3 opened a new issue, #9447:
URL: https://github.com/apache/rocketmq/issues/9447

   ### Before Creating the Enhancement Request
   
   - [x] I have confirmed that this should be classified as an enhancement 
rather than a bug/feature.
   
   
   ### Summary
   
   # leak 1
   `org.apache.rocketmq.container.BrokerContainerStartup#loadConfig`  
InputStream in.
   
   
![Image](https://github.com/user-attachments/assets/505279e1-5af8-4617-9074-24909b033c2b)
   
   If an exception occurs during `properties.load(in)`, the `in.close()` line 
will be skipped, and the `InputStream` will not be closed.
   # leak 2
   `org.apache.rocketmq.test.schema.SchemaTools#load`  BufferedReader br.
   
   
![Image](https://github.com/user-attachments/assets/a5a22c20-182a-4f27-ba8f-a62c492cf3f7)
   
   The line `br.close();` is intended to release this resource. However, it 
might be skipped if an exception occurs within the while loop.
   
   # leak 3
   `org.apache.rocketmq.remoting.protocol.body.RegisterBrokerBody#decode` 
InflaterInputStream inflaterInputStream
   
   inflaterInputStream is never closed.
   
   # leak 4
   `org.apache.rocketmq.remoting.protocol.body.RegisterBrokerBody#encode`  
DeflaterOutputStream outputStream
   outputStream is never closed.
   
   # leak 5 
   
`org.apache.rocketmq.test.util.DuplicateMessageInfo#checkDuplicatedMessageInfo` 
OutputStream out
   
   
![Image](https://github.com/user-attachments/assets/7ef52248-6455-4a23-81c0-6d424c4f6738)
   
   The code attempts to close the stream with out.close();. However, if an 
exception occurs after the FileOutputStream is successfully opened but before 
out.close() is executed, the close() call will be skipped.
   
   # leak 6
   `org.apache.rocketmq.broker.BrokerStartup#loadConfig` InputStream in
   
   
![Image](https://github.com/user-attachments/assets/42461469-7f6a-436d-91c0-fc882fa62a8b)
   same as leak 1
   
   
   ### Motivation
   
   This enhancement effort revealed potential resource leaks. Recurrent leakage 
would cause an aggregation of unreleased resources, ultimately leading to the 
depletion of system resources available to the application.
   
   ### Describe the Solution You'd Like
   
   `try-with-resources` solutions effectively address the resource leak.
   
   ### Describe Alternatives You've Considered
   
   Proposed solution is widely recognized as the most effective and appropriate 
method.
   
   ### Additional Context
   
   _No response_


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