bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-872: Resource leak with unclosed LedgerManager in HierarchicalLedgerManagerFactory#format() (Ted Yu via sijie)
Date Sat, 10 Oct 2015 16:38:29 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master 885cebf11 -> 9803ee8e6


BOOKKEEPER-872: Resource leak with unclosed LedgerManager in HierarchicalLedgerManagerFactory#format()
(Ted Yu via sijie)


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/9803ee8e
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/9803ee8e
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/9803ee8e

Branch: refs/heads/master
Commit: 9803ee8e6293dcd0346b1ca3cb0f2666b5e12382
Parents: 885cebf
Author: Sijie Guo <sijie@apache.org>
Authored: Sat Oct 10 09:38:11 2015 -0700
Committer: Sijie Guo <sijie@apache.org>
Committed: Sat Oct 10 09:38:11 2015 -0700

----------------------------------------------------------------------
 CHANGES.txt                                         |  2 ++
 .../bookkeeper/meta/FlatLedgerManagerFactory.java   | 16 ++++++++++------
 .../meta/HierarchicalLedgerManagerFactory.java      | 16 ++++++++++------
 3 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9803ee8e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 504934b..3e91989 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -44,6 +44,8 @@ Trunk (unreleased changes)
 
       BOOKKEEPER-826: PendingAddOp is ignoring ack response after meet ack quorum constraint
(sijie)
 
+      BOOKKEEPER-872: Resource leak with unclosed LedgerManager in HierarchicalLedgerManagerFactory#format()
(Ted Yu via sijie)
+
     IMPROVEMENTS:
 
       BOOKKEEPER-800: Expose whether a ledger is closed or not (ivank)

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9803ee8e/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
index 46f8b9b..78a1867 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
@@ -83,13 +83,17 @@ public class FlatLedgerManagerFactory extends LedgerManagerFactory {
     public void format(AbstractConfiguration conf, ZooKeeper zk)
             throws InterruptedException, KeeperException, IOException {
         FlatLedgerManager ledgerManager = (FlatLedgerManager) newLedgerManager();
-        String ledgersRootPath = conf.getZkLedgersRootPath();
-        List<String> children = zk.getChildren(ledgersRootPath, false);
-        for (String child : children) {
-            if (ledgerManager.isSpecialZnode(child)) {
-                continue;
+        try {
+            String ledgersRootPath = conf.getZkLedgersRootPath();
+            List<String> children = zk.getChildren(ledgersRootPath, false);
+            for (String child : children) {
+                if (ledgerManager.isSpecialZnode(child)) {
+                    continue;
+                }
+                ZKUtil.deleteRecursive(zk, ledgersRootPath + "/" + child);
             }
-            ZKUtil.deleteRecursive(zk, ledgersRootPath + "/" + child);
+        } finally {
+            ledgerManager.close();
         }
         // Delete and recreate the LAYOUT information.
         super.format(conf, zk);

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9803ee8e/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
index a165b0d..dac9e96 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
@@ -83,13 +83,17 @@ public class HierarchicalLedgerManagerFactory extends LedgerManagerFactory
{
     public void format(AbstractConfiguration conf, ZooKeeper zk)
             throws InterruptedException, KeeperException, IOException {
         HierarchicalLedgerManager ledgerManager = (HierarchicalLedgerManager) newLedgerManager();
-        String ledgersRootPath = conf.getZkLedgersRootPath();
-        List<String> children = zk.getChildren(ledgersRootPath, false);
-        for (String child : children) {
-            if (ledgerManager.isSpecialZnode(child)) {
-                continue;
+        try {
+            String ledgersRootPath = conf.getZkLedgersRootPath();
+            List<String> children = zk.getChildren(ledgersRootPath, false);
+            for (String child : children) {
+                if (ledgerManager.isSpecialZnode(child)) {
+                    continue;
+                }
+                ZKUtil.deleteRecursive(zk, ledgersRootPath + "/" + child);
             }
-            ZKUtil.deleteRecursive(zk, ledgersRootPath + "/" + child);
+        } finally {
+            ledgerManager.close();
         }
         // Delete and recreate the LAYOUT information.
         super.format(conf, zk);


Mime
View raw message