accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] git commit: ACCUMULO-3228 fix possible resource leaks
Date Fri, 10 Oct 2014 22:55:46 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6 9aca7d74d -> 71e5f6b97


ACCUMULO-3228 fix possible resource leaks


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

Branch: refs/heads/1.6
Commit: f55d0bf99a3965ff3d0b0c922cc2b1867d212044
Parents: 3a73e25
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Fri Oct 10 18:41:54 2014 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Fri Oct 10 18:41:54 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/file/rfile/RFile.java  | 45 ++++++++++----------
 .../minicluster/MiniAccumuloRunner.java         |  4 +-
 .../apache/accumulo/test/scalability/Run.java   |  7 ++-
 3 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f55d0bf9/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
index da5a3ea..acb5656 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
@@ -823,30 +823,31 @@ public class RFile {
       this.reader = rdr;
       
       ABlockReader mb = reader.getMetaBlock("RFile.index");
-      
-      int magic = mb.readInt();
-      int ver = mb.readInt();
-      
-      if (magic != RINDEX_MAGIC)
-        throw new IOException("Did not see expected magic number, saw " + magic);
-      if (ver != RINDEX_VER_7 && ver != RINDEX_VER_6 && ver != RINDEX_VER_4
&& ver != RINDEX_VER_3)
-        throw new IOException("Did not see expected version, saw " + ver);
-      
-      int size = mb.readInt();
-      lgReaders = new LocalityGroupReader[size];
-      
-      deepCopies = new LinkedList<Reader>();
-      
-      for (int i = 0; i < size; i++) {
-        LocalityGroupMetadata lgm = new LocalityGroupMetadata(ver, rdr);
-        lgm.readFields(mb);
-        localityGroups.add(lgm);
-        
-        lgReaders[i] = new LocalityGroupReader(reader, lgm, ver);
+      try{
+        int magic = mb.readInt();
+        int ver = mb.readInt();
+
+        if (magic != RINDEX_MAGIC)
+          throw new IOException("Did not see expected magic number, saw " + magic);
+        if (ver != RINDEX_VER_7 && ver != RINDEX_VER_6 && ver != RINDEX_VER_4
&& ver != RINDEX_VER_3)
+          throw new IOException("Did not see expected version, saw " + ver);
+
+        int size = mb.readInt();
+        lgReaders = new LocalityGroupReader[size];
+
+        deepCopies = new LinkedList<Reader>();
+
+        for (int i = 0; i < size; i++) {
+          LocalityGroupMetadata lgm = new LocalityGroupMetadata(ver, rdr);
+          lgm.readFields(mb);
+          localityGroups.add(lgm);
+
+          lgReaders[i] = new LocalityGroupReader(reader, lgm, ver);
+        }
+      } finally {
+        mb.close();
       }
       
-      mb.close();
-      
       nonDefaultColumnFamilies = new HashSet<ByteSequence>();
       for (LocalityGroupMetadata lgm : localityGroups) {
         if (!lgm.isDefaultLG)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/f55d0bf9/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
index cd4a465..e261faa 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.ServerSocket;
+import java.net.Socket;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,7 +31,6 @@ import java.util.regex.Pattern;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.commons.io.FileUtils;
-
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
 import com.google.common.io.Files;
@@ -208,7 +208,7 @@ public class MiniAccumuloRunner {
 
     // start a socket on the shutdown port and block- anything connected to this port will
activate the shutdown
     ServerSocket shutdownServer = new ServerSocket(shutdownPort);
-    shutdownServer.accept();
+    shutdownServer.accept().close();
 
     System.exit(0);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/f55d0bf9/test/src/main/java/org/apache/accumulo/test/scalability/Run.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/scalability/Run.java b/test/src/main/java/org/apache/accumulo/test/scalability/Run.java
index 8c3e371..d42af8c 100644
--- a/test/src/main/java/org/apache/accumulo/test/scalability/Run.java
+++ b/test/src/main/java/org/apache/accumulo/test/scalability/Run.java
@@ -58,8 +58,11 @@ public class Run {
     Properties testProps = new Properties();
     try {
       FileInputStream fis = new FileInputStream(sitePath);
-      scaleProps.load(fis);
-      fis.close();
+      try {
+        scaleProps.load(fis);
+      } finally {
+        fis.close();
+      }
       fis = new FileInputStream(testPath);
       testProps.load(fis);
     } catch (Exception e) {


Mime
View raw message