### Eclipse Workspace Patch 1.0 #P hbase svn Index: src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java (revision 1292909) +++ src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java (working copy) @@ -145,25 +145,31 @@ byte[] searchRow = HRegionInfo.createRegionName(tableName, row, HConstants.NINES, false); + HTable metaTable = null; + try{ + metaTable = new HTable(configuration, HConstants.META_TABLE_NAME); + Result startRowResult = metaTable.getRowOrBefore(searchRow, + HConstants.CATALOG_FAMILY); + if (startRowResult == null) { + throw new TableNotFoundException("Cannot find row in .META. for table: " + + Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow)); + } + byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY, + HConstants.REGIONINFO_QUALIFIER); + if (value == null || value.length == 0) { + throw new IOException("HRegionInfo was null or empty in Meta for " + + Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow)); + } + HRegionInfo regionInfo = Writables.getHRegionInfo(value); - HTable metaTable = new HTable(configuration, HConstants.META_TABLE_NAME); - Result startRowResult = metaTable.getRowOrBefore(searchRow, - HConstants.CATALOG_FAMILY); - if (startRowResult == null) { - throw new TableNotFoundException("Cannot find row in .META. for table: " - + Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow)); - } - byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY, - HConstants.REGIONINFO_QUALIFIER); - if (value == null || value.length == 0) { - throw new IOException("HRegionInfo was null or empty in Meta for " + - Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow)); + byte[] rowBefore = regionInfo.getStartKey(); + startRow = HRegionInfo.createRegionName(tableName, rowBefore, + HConstants.ZEROES, false); + }finally{ + if(metaTable!=null){ + metaTable.close(); + } } - HRegionInfo regionInfo = Writables.getHRegionInfo(value); - - byte[] rowBefore = regionInfo.getStartKey(); - startRow = HRegionInfo.createRegionName(tableName, rowBefore, - HConstants.ZEROES, false); } else if (tableName == null || tableName.length == 0) { // Full META scan startRow = HConstants.EMPTY_START_ROW;