HBASE-15369 Handle NPE in region.jsp (Samir Ahmic)

This commit is contained in:
tedyu 2016-04-06 06:52:51 -07:00
parent c93cffb95c
commit 3826894f89
1 changed files with 15 additions and 3 deletions

View File

@ -21,6 +21,7 @@
import="java.util.Collection" import="java.util.Collection"
import="java.util.Date" import="java.util.Date"
import="java.util.List" import="java.util.List"
import="org.owasp.esapi.ESAPI"
import="static org.apache.commons.lang.StringEscapeUtils.escapeXml" import="static org.apache.commons.lang.StringEscapeUtils.escapeXml"
import="org.apache.hadoop.conf.Configuration" import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.HTableDescriptor" import="org.apache.hadoop.hbase.HTableDescriptor"
@ -35,10 +36,14 @@
String regionName = request.getParameter("name"); String regionName = request.getParameter("name");
HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER); HRegionServer rs = (HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
Configuration conf = rs.getConfiguration(); Configuration conf = rs.getConfiguration();
String displayName = null;
Region region = rs.getFromOnlineRegions(regionName); Region region = rs.getFromOnlineRegions(regionName);
String displayName = HRegionInfo.getRegionNameAsStringForDisplay(region.getRegionInfo(), if(region == null) {
displayName= ESAPI.encoder().encodeForHTML(regionName) + " does not exist";
} else {
displayName = HRegionInfo.getRegionNameAsStringForDisplay(region.getRegionInfo(),
rs.getConfiguration()); rs.getConfiguration());
}
%> %>
<!--[if IE]> <!--[if IE]>
<!DOCTYPE html> <!DOCTYPE html>
@ -121,7 +126,14 @@
<p> <%= storeFiles.size() %> StoreFile(s) in set.</p> <p> <%= storeFiles.size() %> StoreFile(s) in set.</p>
</table> </table>
<% } <% }
}%> } else { %>
<div class="container-fluid content">
<div class="row inner_header">
</div>
<p><hr><p>
<p>Go <a href="javascript:history.back()">Back</a>
</div>
<% } %>
</div> </div>
<script src="/static/js/jquery.min.js" type="text/javascript"></script> <script src="/static/js/jquery.min.js" type="text/javascript"></script>
<script src="/static/js/bootstrap.min.js" type="text/javascript"></script> <script src="/static/js/bootstrap.min.js" type="text/javascript"></script>