----- Original Message ----- From: "Leffingwell, Jonathan R CTR FRCSE, JAX 7.2.2" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Thursday, June 12, 2008 4:44 PM
Subject: getAttribute(null)?


I have the following code that worked in Tomcat 5.0, but doesn't work in
Tomcat 5.5.26:

String formName = mapping.getAttribute();   // mapping is a variable of
type ActionMapping. In this scenario, formName is null.

if (null != session.getAttribute(formName)) {
session.removeAttribute(formName);
}


formName is null.  In Tomcat 5.0.x, no exception was thrown and
processing continued (as if passing a null argument to getAttribute
simply returned NULL).  In Tomcat 5.5.26, a ServletException is thrown
(with a NullPointerException).

I know how to code a work-around (and have done so), but is this
considered a bug in Tomcat?

======TEST======
This code
           HttpSession session = request.getSession(true);
           Object obj = session.getAttribute(null);

Raises this exception

java.lang.NullPointerException
java.util.Hashtable.get(Unknown Source)
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1024)
 
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110)
 NewServlet.processRequest(NewServlet.java:29) 
NewServlet.doGet(NewServlet.java:52) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)The Hash Table is 
throwing it...I'm too young to remember 5 ;)But you maybe right, its possible 
that the internals used to use a Vector...and when Java introduced new 
collections, it changed.You may have spotted a little regression issue, but 
probably something thathasnt caught too many people.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to