From 7037e77f8f3f639a0276fca790e04b73dc24662e Mon Sep 17 00:00:00 2001 From: "andi@symphono.com" Date: Thu, 11 Jun 2015 14:47:18 -0500 Subject: [PATCH] OF-889: Added try-catch blocks to the various JSP pages where Session.getHostName or Session.getHostAddress is called to prevent the Sessions tab from showing UnknownHostExceptions when there are bad client sessions laying around --- src/web/component-session-details.jsp | 10 +++++++--- src/web/server-session-details.jsp | 22 +++++++++++++--------- src/web/session-details.jsp | 10 +++++++--- src/web/session-row.jspf | 6 +++++- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/web/component-session-details.jsp b/src/web/component-session-details.jsp index bedc9723b6..5075c898b5 100644 --- a/src/web/component-session-details.jsp +++ b/src/web/component-session-details.jsp @@ -151,9 +151,13 @@ - <%= StringUtils.escapeHTMLTags(componentSession.getHostAddress()) %> - / - <%= StringUtils.escapeHTMLTags(componentSession.getHostName()) %> + <% try { %> + <%= StringUtils.escapeHTMLTags(componentSession.getHostAddress()) %> + / + <%= StringUtils.escapeHTMLTags(componentSession.getHostName()) %> + <% } catch (java.net.UnknownHostException e) { %> + Invalid session/connection + <% } %> diff --git a/src/web/server-session-details.jsp b/src/web/server-session-details.jsp index 3c1c8f3ffc..5bf0a0b52a 100644 --- a/src/web/server-session-details.jsp +++ b/src/web/server-session-details.jsp @@ -22,7 +22,7 @@ org.jivesoftware.openfire.session.OutgoingServerSession, org.jivesoftware.util.JiveGlobals, org.jivesoftware.util.ParamUtils, - java.text.NumberFormat" + java.text.NumberFormat" errorPage="error.jsp" %> <%@ page import="java.util.Calendar" %> @@ -99,14 +99,18 @@ - <% if (!inSessions.isEmpty()) { %> - <%= inSessions.get(0).getHostAddress() %> - / - <%= inSessions.get(0).getHostName() %> - <% } else if (outSession != null) { %> - <%= outSession.getHostAddress() %> - / - <%= outSession.getHostName() %> + <% try { + if (!inSessions.isEmpty()) { %> + <%= inSessions.get(0).getHostAddress() %> + / + <%= inSessions.get(0).getHostName() %> + <% } else if (outSession != null) { %> + <%= outSession.getHostAddress() %> + / + <%= outSession.getHostName() %> + <% } + } catch (java.net.UnknownHostException e) { %> + Invalid session/connection <% } %> diff --git a/src/web/session-details.jsp b/src/web/session-details.jsp index 185ae9c138..7e29789e7d 100644 --- a/src/web/session-details.jsp +++ b/src/web/session-details.jsp @@ -281,9 +281,13 @@ - <%= currentSess.getHostAddress() %> - / - <%= currentSess.getHostName() %> + <% try { %> + <%= currentSess.getHostAddress() %> + / + <%= currentSess.getHostName() %> + <% } catch (java.net.UnknownHostException e) { %> + Invalid session/connection + <% } %> diff --git a/src/web/session-row.jspf b/src/web/session-row.jspf index bb6cf21eff..945a0773ca 100644 --- a/src/web/session-row.jspf +++ b/src/web/session-row.jspf @@ -168,7 +168,11 @@ - <%= sess.getHostAddress() %> + <% try { %> + <%= sess.getHostAddress() %> + <% } catch (java.net.UnknownHostException e) { %> + Invalid session/connection + <% } %>