zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1398995 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
Date Tue, 16 Oct 2012 21:20:27 GMT
Author: ivank
Date: Tue Oct 16 21:20:26 2012
New Revision: 1398995

URL: http://svn.apache.org/viewvc?rev=1398995&view=rev
Log:
BOOKKEEPER-436: Journal#rollLog may leak file handler (umamahesh via ivank)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1398995&r1=1398994&r2=1398995&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Tue Oct 16 21:20:26 2012
@@ -94,6 +94,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-417: Hierarchical zk underreplication manager should clean up its hierarchy
when done to allow for fast acquisition of underreplicated entries (ivank)
 
+        BOOKKEEPER-436: Journal#rollLog may leak file handler (umamahesh via ivank)
+
       hedwig-protocol:
 
         BOOKKEEPER-394: CompositeException message is not useful (Stu Hood via sijie)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java?rev=1398995&r1=1398994&r2=1398995&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
Tue Oct 16 21:20:26 2012
@@ -120,15 +120,22 @@ class Journal extends Thread {
             bb.putLong(lastMark.getTxnLogId());
             bb.putLong(lastMark.getTxnLogPosition());
             LOG.debug("RollLog to persist last marked log : {}", lastMark);
-            for(File dir: ledgerDirectories) {
+            for (File dir : ledgerDirectories) {
                 File file = new File(dir, "lastMark");
+                FileOutputStream fos = null;
                 try {
-                    FileOutputStream fos = new FileOutputStream(file);
+                    fos = new FileOutputStream(file);
                     fos.write(buff);
                     fos.getChannel().force(true);
                     fos.close();
+                    fos = null;
                 } catch (IOException e) {
                     LOG.error("Problems writing to " + file, e);
+                } finally {
+                    // if stream already closed in try block successfully,
+                    // stream might have nullified, in such case below
+                    // call will simply returns
+                    IOUtils.close(LOG, fos);
                 }
             }
         }



Mime
View raw message