From 1848353fd60b2c51282552e9d0ad284be601cca5 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sat, 22 Apr 2017 18:16:20 +0530 Subject: [PATCH] HBASE-17879: Avoid NPE in snapshot.jsp when accessing without any request parameter Signed-off-by: Chia-Ping Tsai --- .../hbase-webapps/master/snapshot.jsp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp index 75f75fcbc68..ad3ede5f572 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp @@ -36,14 +36,16 @@ SnapshotInfo.SnapshotStats stats = null; TableName snapshotTable = null; boolean tableExists = false; - try (Admin admin = master.getConnection().getAdmin()) { - for (SnapshotDescription snapshotDesc: admin.listSnapshots()) { - if (snapshotName.equals(snapshotDesc.getName())) { - snapshot = snapshotDesc; - stats = SnapshotInfo.getSnapshotStats(conf, snapshot); - snapshotTable = snapshot.getTableName(); - tableExists = admin.tableExists(snapshotTable); - break; + if(snapshotName != null) { + try (Admin admin = master.getConnection().getAdmin()) { + for (SnapshotDescription snapshotDesc: admin.listSnapshots()) { + if (snapshotName.equals(snapshotDesc.getName())) { + snapshot = snapshotDesc; + stats = SnapshotInfo.getSnapshotStats(conf, snapshot); + snapshotTable = snapshot.getTableName(); + tableExists = admin.tableExists(snapshotTable); + break; + } } } } @@ -110,7 +112,7 @@

Go Back, or wait for the redirect.