diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index c2781541db..825d3a8c9e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 5352d669e7..36a81b00d3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -741,14 +741,15 @@ public int run(Configuration conf, List args) throws IOException { RemoteIterator 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; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java index 4d807cbbef..9a418c2149 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java @@ -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; }