markt 2004/02/12 12:52:52 Modified: catalina/src/share/org/apache/catalina/session LocalStrings.properties StandardSession.java Log: Fix bug 14283. Catch and log exceptions in listeners. Reported by Eddie Ruvinsky. Revision Changes Path 1.13 +1 -0 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/LocalStrings.properties,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- LocalStrings.properties 31 Dec 2002 12:56:35 -0000 1.12 +++ LocalStrings.properties 12 Feb 2004 20:52:52 -0000 1.13 @@ -34,6 +34,7 @@ standardManager.managerLoad=Exception loading sessions from persistent storage standardManager.managerUnload=Exception unloading sessions to persistent storage standardSession.attributeEvent=Session attribute event listener threw exception +standardSession.bindingEvent=Session binding event listener threw exception standardSession.invalidate.ise=invalidate: Session already invalidated standardSession.isNew.ise=isNew: Session already invalidated standardSession.getAttribute.ise=getAttribute: Session already invalidated 1.38 +33 -14 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java Index: StandardSession.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- StandardSession.java 18 Jan 2004 20:38:35 -0000 1.37 +++ StandardSession.java 12 Feb 2004 20:52:52 -0000 1.38 @@ -78,7 +78,6 @@ import java.util.HashMap; import java.util.Iterator; import javax.servlet.ServletContext; -import javax.servlet.ServletException; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionActivationListener; import javax.servlet.http.HttpSessionAttributeListener; @@ -696,8 +695,11 @@ if (attribute instanceof HttpSessionActivationListener) { if (event == null) event = new HttpSessionEvent(this); - // FIXME: Should we catch throwables? - ((HttpSessionActivationListener)attribute).sessionWillPassivate(event); + try { + ((HttpSessionActivationListener)attribute).sessionWillPassivate(event); + } catch (Throwable t) { + log(sm.getString("standardSession.attributeEvent"), t); + } } } @@ -718,8 +720,11 @@ if (attribute instanceof HttpSessionActivationListener) { if (event == null) event = new HttpSessionEvent(this); - // FIXME: Should we catch throwables? - ((HttpSessionActivationListener)attribute).sessionDidActivate(event); + try { + ((HttpSessionActivationListener)attribute).sessionDidActivate(event); + } catch (Throwable t) { + log(sm.getString("standardSession.attributeEvent"), t); + } } } @@ -1150,8 +1155,13 @@ HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession) this, name, value); if ((value != null) && - (value instanceof HttpSessionBindingListener)) - ((HttpSessionBindingListener) value).valueUnbound(event); + (value instanceof HttpSessionBindingListener)) { + try { + ((HttpSessionBindingListener) value).valueUnbound(event); + } catch (Throwable t) { + log(sm.getString("standardSession.bindingEvent"), t); + } + } // Notify interested application event listeners Context context = (Context) manager.getContainer(); @@ -1255,8 +1265,13 @@ ((HttpSession) this, name, value); // Call the valueBound() method if necessary - if (value instanceof HttpSessionBindingListener) + if (value instanceof HttpSessionBindingListener) { + try { ((HttpSessionBindingListener) value).valueBound(event); + } catch (Throwable t) { + log(sm.getString("standardSession.bindingEvent"), t); + } + } // Replace or add this attribute Object unbound = null; @@ -1268,8 +1283,12 @@ // Call the valueUnbound() method if necessary if ((unbound != null) && (unbound instanceof HttpSessionBindingListener)) { - ((HttpSessionBindingListener) unbound).valueUnbound - (new HttpSessionBindingEvent((HttpSession) this, name)); + try { + ((HttpSessionBindingListener) unbound).valueUnbound + (new HttpSessionBindingEvent((HttpSession) this, name)); + } catch (Throwable t) { + log(sm.getString("standardSession.bindingEvent"), t); + } } // Replace the current event with one containing
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]