HBASE-22704 Avoid NPE when access table.jsp and snapshot.jsp but master not finish initialization (#389)

This commit is contained in:
Guanghao 2019-07-18 08:20:36 +08:00 committed by Guanghao Zhang
parent fa35bbc0d2
commit c5af92b644
2 changed files with 11 additions and 4 deletions

View File

@ -36,7 +36,7 @@
SnapshotInfo.SnapshotStats stats = null;
TableName snapshotTable = null;
boolean tableExists = false;
if(snapshotName != null) {
if(snapshotName != null && master.isInitialized()) {
try (Admin admin = master.getConnection().getAdmin()) {
for (SnapshotDescription snapshotDesc: admin.listSnapshots()) {
if (snapshotName.equals(snapshotDesc.getName())) {
@ -66,7 +66,14 @@
</jsp:include>
<div class="container-fluid content">
<% if (snapshot == null) { %>
<% if (!master.isInitialized()) { %>
<div class="row inner_header">
<div class="page-header">
<h1>Master is not initialized</h1>
</div>
</div>
<jsp:include page="redirect.jsp" />
<% } else if (snapshot == null) { %>
<div class="row inner_header">
<div class="page-header">
<h1>Snapshot "<%= snapshotName %>" does not exist</h1>

View File

@ -126,7 +126,7 @@
</jsp:include>
<%
if ( fqtn != null ) {
if (fqtn != null && master.isInitialized()) {
try {
table = master.getConnection().getTable(TableName.valueOf(fqtn));
if (table.getTableDescriptor().getRegionReplication() > 1) {
@ -684,7 +684,7 @@ Actions:
</div> <%
}
}
else { // handle the case for fqtn is null with error message + redirect
else { // handle the case for fqtn is null or master is not initialized with error message + redirect
%>
<div class="container-fluid content">
<div class="row inner_header">