Skip to content

Commit

Permalink
Fix NPE when accessing region.jsp without specifying a region name
Browse files Browse the repository at this point in the history
  • Loading branch information
guluo2016 committed Sep 3, 2024
1 parent 27f8230 commit 3cb4df9
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,22 @@
String regionName = request.getParameter("name");
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
FileSystem fs = rs.getFileSystem();
HRegion region = rs.getRegion(regionName);
HRegion region = null;
if (regionName != null) {
region = rs.getRegion(regionName);
}
String displayName;
boolean isReplicaRegion = false;
if (region != null) {
displayName = RegionInfoDisplay.getRegionNameAsStringForDisplay(region.getRegionInfo(),
rs.getConfiguration());
isReplicaRegion = region.getRegionInfo().getReplicaId() > RegionInfo.DEFAULT_REPLICA_ID;
} else {
displayName = "region {" + regionName + "} is not currently online on this region server";
if (regionName != null) {
displayName = "region {" + regionName + "} is not currently online on this region server";
} else {
displayName = "you must specify a region name when accessing this page";
}
}
pageContext.setAttribute("pageTitle", "HBase RegionServer: " + rs.getServerName());
%>
Expand Down

0 comments on commit 3cb4df9

Please sign in to comment.