Description
Before Creating the Enhancement Request
- 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.
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.
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
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
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