HBASE-10369 LabelExpander#createLabels() should close scanner in finally clause
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1558975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c661d926c0
commit
4c2c982faa
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue