hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1558976 - /hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java
Date Fri, 17 Jan 2014 01:34:25 GMT
Author: tedyu
Date: Fri Jan 17 01:34:25 2014
New Revision: 1558976

URL: http://svn.apache.org/r1558976
Log:
HBASE-10369 LabelExpander#createLabels() should close scanner in finally clause


Modified:
    hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java

Modified: hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java?rev=1558976&r1=1558975&r2=1558976&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java
(original)
+++ hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LabelExpander.java
Fri Jan 17 01:34:25 2014
@@ -140,13 +140,14 @@ public class LabelExpander {
     // This scan should be done by user with global_admin previliges.. Ensure
     // that it works
     HTable visibilityLabelsTable = null;
+    ResultScanner scanner = null;
     try {
       labels = new HashMap<String, Integer>();
       visibilityLabelsTable = new HTable(conf, LABELS_TABLE_NAME.getName());
       Scan scan = new Scan();
       scan.setAuthorizations(new Authorizations(VisibilityUtils.SYSTEM_LABEL));
       scan.addColumn(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
-      ResultScanner scanner = visibilityLabelsTable.getScanner(scan);
+      scanner = visibilityLabelsTable.getScanner(scan);
       while (true) {
         Result next = scanner.next();
         if (next == null) {
@@ -156,10 +157,15 @@ public class LabelExpander {
         byte[] value = next.getValue(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
         labels.put(Bytes.toString(value), Bytes.toInt(row));
       }
-      scanner.close();
     } finally {
-      if (visibilityLabelsTable != null) {
-        visibilityLabelsTable.close();
+      try {
+        if (scanner != null) {
+          scanner.close();
+        }
+      } finally {
+        if (visibilityLabelsTable != null) {
+          visibilityLabelsTable.close();
+        }
       }
     }
   }



Mime
View raw message