HDFS-5512. CacheAdmin -listPools fails with NPE when user lacks permissions to view all pools (awang via cmccabe)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1543293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Colin McCabe 2013-11-19 02:35:34 +00:00
parent 4f15d0af4f
commit 70234e2213
3 changed files with 14 additions and 7 deletions

View File

@ -378,6 +378,9 @@ Trunk (Unreleased)
HDFS-5520. loading cache path directives from edit log doesn't update
nextEntryId (cmccabe)
HDFS-5512. CacheAdmin -listPools fails with NPE when user lacks permissions
to view all pools (awang via cmccabe)
Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -741,14 +741,15 @@ public int run(Configuration conf, List<String> args) throws IOException {
RemoteIterator<CachePoolInfo> iter = dfs.listCachePools();
while (iter.hasNext()) {
CachePoolInfo info = iter.next();
String[] row = new String[5];
if (name == null || info.getPoolName().equals(name)) {
listing.addRow(new String[] {
info.getPoolName(),
info.getOwnerName(),
info.getGroupName(),
info.getMode().toString(),
info.getWeight().toString(),
});
row[0] = info.getPoolName();
row[1] = info.getOwnerName();
row[2] = info.getGroupName();
row[3] = info.getMode() != null ? info.getMode().toString() : null;
row[4] =
info.getWeight() != null ? info.getWeight().toString() : null;
listing.addRow(row);
++numResults;
if (name != null) {
break;

View File

@ -59,6 +59,9 @@ private static class Column {
}
private void addRow(String val) {
if (val == null) {
val = "";
}
if ((val.length() + 1) > maxWidth) {
maxWidth = val.length() + 1;
}