This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 51778a37fe Avoid three unlikely NPE 51778a37fe is described below commit 51778a37fec8d3aa13a3ccf1884daf4f3d709c1c Author: remm <r...@apache.org> AuthorDate: Fri Sep 8 13:02:41 2023 +0200 Avoid three unlikely NPE Found by coverity. --- java/org/apache/catalina/manager/HTMLManagerServlet.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/java/org/apache/catalina/manager/HTMLManagerServlet.java b/java/org/apache/catalina/manager/HTMLManagerServlet.java index d38777d9a9..8c94019e87 100644 --- a/java/org/apache/catalina/manager/HTMLManagerServlet.java +++ b/java/org/apache/catalina/manager/HTMLManagerServlet.java @@ -246,7 +246,7 @@ public final class HTMLManagerServlet extends ManagerServlet { break; } String filename = warPart.getSubmittedFileName(); - if (!filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) { + if (filename == null || !filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) { message = smClient.getString( "htmlManagerServlet.deployUploadNotWar", filename); break; @@ -1019,8 +1019,7 @@ public final class HTMLManagerServlet extends ManagerServlet { } int nbAffectedSessions = 0; for (String sessionId : sessionIds) { - HttpSession session = - getSessionForNameAndId(cn, sessionId, smClient).getSession(); + Session session = getSessionForNameAndId(cn, sessionId, smClient); if (null == session) { // Shouldn't happen, but let's play nice... if (debug >= 1) { @@ -1029,7 +1028,7 @@ public final class HTMLManagerServlet extends ManagerServlet { continue; } try { - session.invalidate(); + session.getSession().invalidate(); ++nbAffectedSessions; if (debug >= 1) { log("Invalidating session id " + sessionId); @@ -1054,8 +1053,7 @@ public final class HTMLManagerServlet extends ManagerServlet { */ protected boolean removeSessionAttribute(ContextName cn, String sessionId, String attributeName, StringManager smClient) { - HttpSession session = - getSessionForNameAndId(cn, sessionId, smClient).getSession(); + Session session = getSessionForNameAndId(cn, sessionId, smClient); if (null == session) { // Shouldn't happen, but let's play nice... if (debug >= 1) { @@ -1063,9 +1061,10 @@ public final class HTMLManagerServlet extends ManagerServlet { } return false; } - boolean wasPresent = (null != session.getAttribute(attributeName)); + HttpSession httpSession = session.getSession(); + boolean wasPresent = (null != httpSession.getAttribute(attributeName)); try { - session.removeAttribute(attributeName); + httpSession.removeAttribute(attributeName); } catch (IllegalStateException ise) { if (debug >= 1) { log("Cannot remote attribute '" + attributeName + "' for invalidated session id " + sessionId); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org