From 7c5f4eeed81f768ec071a678f11e939923258905 Mon Sep 17 00:00:00 2001 From: Peng Lu Date: Thu, 5 Sep 2024 20:07:36 +0800 Subject: [PATCH] HBASE-28778 NPE may occur when opening master-status or table.jsp or procedure.jsp while Master is initializing (#6152) Signed-off-by: Duo Zhang (cherry picked from commit 3caaf2d739106b56ab94a0561e730ff35802610d) --- .../resources/hbase-webapps/master/table.jsp | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index 7773151de8ad..ced96b07ebaf 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -147,11 +147,32 @@ return ""; } %> + + + + + <% 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()) { +%> +
+
+ +
+


+ +

+<% 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); @@ -200,24 +221,6 @@ final MetaBrowser metaBrowser = new MetaBrowser(connection, request); %> - - - - -<% // handle the case for fqtn is null or master is not initialized with error message + redirect - if (fqtn == null || ! master.isInitialized()) { %> -
-
- -
-


- -

-<% return; - } %> - <% // unknow table if (! admin.tableExists(TableName.valueOf(fqtn)).get()) { %>