Skip to content

Commit

Permalink
HBASE-28778 NPE may occur when opening master-status or table.jsp or …
Browse files Browse the repository at this point in the history
…procedure.jsp while Master is initializing (apache#6152)

Signed-off-by: Duo Zhang <[email protected]>
(cherry picked from commit 3caaf2d)
  • Loading branch information
guluo2016 authored and PDavid committed Dec 13, 2024
1 parent 2de2804 commit 0ead11c
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions hbase-server/src/main/resources/hbase-webapps/master/table.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,32 @@
return "";
}
%>

<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>

<%
final String ZEROMB = "0 MB";
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
Configuration conf = master.getConfiguration();
String fqtn = request.getParameter("name");
// handle the case for fqtn is null or master is not initialized with error message + redirect
if (fqtn == null || !master.isInitialized()) {
%>
<div class="container-fluid content">
<div class="row inner_header">
<div class="page-header">
<h1>Table not ready</h1>
</div>
</div>
<p><hr><p>
<jsp:include page="redirect.jsp" />
</div>
<% return;
} %>

<%
final String escaped_fqtn = StringEscapeUtils.escapeHtml4(fqtn);
Table table = master.getConnection().getTable(TableName.valueOf(fqtn));
boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
Expand Down Expand Up @@ -200,24 +221,6 @@
final MetaBrowser metaBrowser = new MetaBrowser(connection, request);
%>

<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>

<% // handle the case for fqtn is null or master is not initialized with error message + redirect
if (fqtn == null || ! master.isInitialized()) { %>
<div class="container-fluid content">
<div class="row inner_header">
<div class="page-header">
<h1>Table not ready</h1>
</div>
</div>
<p><hr><p>
<jsp:include page="redirect.jsp" />
</div>
<% return;
} %>

<% // unknow table
if (! admin.tableExists(TableName.valueOf(fqtn)).get()) { %>
<div class="container-fluid content">
Expand Down

0 comments on commit 0ead11c

Please sign in to comment.