HBASE-5424 HTable meet NPE when call getRegionInfo()

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1292645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-02-23 04:43:29 +00:00
parent c3575d2eb5
commit 6a80cf5bf9
1 changed files with 14 additions and 12 deletions

View File

@ -449,24 +449,26 @@ public class HTable implements HTableInterface {
MetaScannerVisitor visitor = new MetaScannerVisitor() { MetaScannerVisitor visitor = new MetaScannerVisitor() {
public boolean processRow(Result rowResult) throws IOException { public boolean processRow(Result rowResult) throws IOException {
HRegionInfo info = Writables.getHRegionInfo( HRegionInfo info = Writables.getHRegionInfoOrNull(
rowResult.getValue(HConstants.CATALOG_FAMILY, rowResult.getValue(HConstants.CATALOG_FAMILY,
HConstants.REGIONINFO_QUALIFIER)); HConstants.REGIONINFO_QUALIFIER));
if (!(Bytes.equals(info.getTableName(), getTableName()))) { if (info != null) {
return false; if (!(Bytes.equals(info.getTableName(), getTableName()))) {
} return false;
}
HServerAddress server = new HServerAddress(); HServerAddress server = new HServerAddress();
byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY, byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
HConstants.SERVER_QUALIFIER); HConstants.SERVER_QUALIFIER);
if (value != null && value.length > 0) { if (value != null && value.length > 0) {
String hostAndPort = Bytes.toString(value); String hostAndPort = Bytes.toString(value);
server = new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(hostAndPort)); server = new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(hostAndPort));
} }
if (!(info.isOffline() || info.isSplit())) { if (!(info.isOffline() || info.isSplit())) {
regionMap.put(new UnmodifyableHRegionInfo(info), server); regionMap.put(new UnmodifyableHRegionInfo(info), server);
}
} }
return true; return true;
} }