HBASE-9649 HFilePrettyPrinter should not throw a NPE if FirstKey or LastKey is null (Jean-Marc Spaggiari)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1526113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2013-09-25 05:45:15 +00:00
parent 91508fd564
commit f6d44db9c6
2 changed files with 9 additions and 2 deletions

View File

@ -1130,9 +1130,12 @@ public class KeyValue implements Cell, HeapSize, Cloneable {
/**
* @param k Key portion of a KeyValue.
* @return Key as a String.
* @return Key as a String, empty string if k is null.
*/
public static String keyToString(final byte [] k) {
if (k == null) {
return "";
}
return keyToString(k, 0, k.length);
}

View File

@ -350,7 +350,11 @@ public class HFilePrettyPrinter {
}
}
System.out.println("Mid-key: " + Bytes.toStringBinary(reader.midkey()));
try {
System.out.println("Mid-key: " + Bytes.toStringBinary(reader.midkey()));
} catch (Exception e) {
System.out.println ("Unable to retrieve the midkey");
}
// Printing general bloom information
DataInput bloomMeta = reader.getGeneralBloomFilterMetadata();