You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by lh...@apache.org on 2025/04/17 11:30:18 UTC
(bookkeeper) 18/20: fix: resource leak when JournalChannel is not fully initialized (#4340)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit 3bac3649d795c066076b193b2b787846ad39b07e
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Thu May 9 18:00:25 2024 +0800
fix: resource leak when JournalChannel is not fully initialized (#4340)
(cherry picked from commit 82a7dd3064bafbdc5be5fedd2bb99b77b814f5cd)
---
.../src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java
index 58be40371d..ef73bfa08f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java
@@ -197,6 +197,7 @@ class JournalChannel implements Closeable {
} else { // open an existing file
fc = channel.getFileChannel();
bc = null; // readonly
+ // readonly, use fileChannel directly, no need to use BufferedChannel
ByteBuffer bb = ByteBuffer.allocate(VERSION_HEADER_SIZE);
int c = fc.read(bb);
@@ -279,6 +280,8 @@ class JournalChannel implements Closeable {
public void close() throws IOException {
if (bc != null) {
bc.close();
+ } else if (fc != null) {
+ fc.close();
}
}