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 GitHub
parent 2afd5d05d4
commit 2b7e33fe52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -129,7 +129,7 @@
</jsp:include>
<%
if ( fqtn != null ) {
if (fqtn != null && master.isInitialized()) {
try {
table = master.getConnection().getTable(TableName.valueOf(fqtn));
if (table.getDescriptor().getRegionReplication() > 1) {
@ -703,7 +703,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">