405540 ServletContextListeners call in reverse in doStop

This commit is contained in:
Greg Wilkins 2013-04-15 14:31:41 +10:00
parent 4e3c7367af
commit a03a5c340b
1 changed files with 6 additions and 11 deletions

View File

@ -818,8 +818,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
if (!_contextListeners.isEmpty()) if (!_contextListeners.isEmpty())
{ {
ServletContextEvent event = new ServletContextEvent(_scontext); ServletContextEvent event = new ServletContextEvent(_scontext);
for (ServletContextListener listener : _contextListeners) for (int i = _contextListeners.size(); i-->0;)
callContextDestroyed(listener,event); callContextDestroyed(_contextListeners.get(i),event);
} }
if (_errorHandler != null) if (_errorHandler != null)
@ -1094,20 +1094,15 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
if (!_requestListeners.isEmpty()) if (!_requestListeners.isEmpty())
{ {
final ServletRequestEvent sre = new ServletRequestEvent(_scontext,request); final ServletRequestEvent sre = new ServletRequestEvent(_scontext,request);
ListIterator<ServletRequestListener> iter = _requestListeners.listIterator(_requestListeners.size()); for (int i=_requestListeners.size();i-->0;)
while (iter.hasNext()) _requestListeners.get(i).requestDestroyed(sre);
iter.next();
while (iter.hasPrevious())
iter.previous().requestDestroyed(sre);
} }
if (!_requestAttributeListeners.isEmpty()) if (!_requestAttributeListeners.isEmpty())
{ {
ListIterator<ServletRequestAttributeListener> iter = _requestAttributeListeners.listIterator(_requestAttributeListeners.size()); ListIterator<ServletRequestAttributeListener> iter = _requestAttributeListeners.listIterator(_requestAttributeListeners.size());
while(iter.hasNext()) for (int i=_requestAttributeListeners.size();i-->0;)
iter.next(); baseRequest.removeEventListener(_requestAttributeListeners.get(i));
while(iter.hasPrevious())
baseRequest.removeEventListener(iter.previous());
} }
} }
} }