HBASE-17879: Avoid NPE in snapshot.jsp when accessing without any request parameter

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Abhishek Kumar 2017-04-22 18:16:20 +05:30 committed by Chia-Ping Tsai
parent 6edb8f8217
commit 1848353fd6
1 changed files with 11 additions and 9 deletions

View File

@ -36,14 +36,16 @@
SnapshotInfo.SnapshotStats stats = null; SnapshotInfo.SnapshotStats stats = null;
TableName snapshotTable = null; TableName snapshotTable = null;
boolean tableExists = false; boolean tableExists = false;
try (Admin admin = master.getConnection().getAdmin()) { if(snapshotName != null) {
for (SnapshotDescription snapshotDesc: admin.listSnapshots()) { try (Admin admin = master.getConnection().getAdmin()) {
if (snapshotName.equals(snapshotDesc.getName())) { for (SnapshotDescription snapshotDesc: admin.listSnapshots()) {
snapshot = snapshotDesc; if (snapshotName.equals(snapshotDesc.getName())) {
stats = SnapshotInfo.getSnapshotStats(conf, snapshot); snapshot = snapshotDesc;
snapshotTable = snapshot.getTableName(); stats = SnapshotInfo.getSnapshotStats(conf, snapshot);
tableExists = admin.tableExists(snapshotTable); snapshotTable = snapshot.getTableName();
break; tableExists = admin.tableExists(snapshotTable);
break;
}
} }
} }
} }
@ -110,7 +112,7 @@
<div class="container-fluid content"> <div class="container-fluid content">
<div class="row inner_header"> <div class="row inner_header">
<div class="page-header"> <div class="page-header">
<h1>Snapshot "<%= snapshotName %>" does not exists</h1> <h1>Snapshot "<%= snapshotName %>" does not exist</h1>
</div> </div>
</div> </div>
<p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect. <p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.