Skip to content

Commit

Permalink
Issue #6277 - Protect from Throwables on HttpSessionListener events.
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
janbartel authored and joakime committed Sep 30, 2021
1 parent 1846b28 commit 09d74ab
Showing 1 changed file with 20 additions and 5 deletions.
Expand Up @@ -18,8 +18,6 @@

package org.eclipse.jetty.server.session;

import static java.lang.Math.round;

import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
Expand All @@ -28,7 +26,6 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -53,6 +50,8 @@
import org.eclipse.jetty.util.statistic.CounterStatistic;
import org.eclipse.jetty.util.statistic.SampleStatistic;

import static java.lang.Math.round;

/**
* An Abstract implementation of SessionManager.
* <p>
Expand Down Expand Up @@ -703,7 +702,16 @@ protected void addSession(AbstractSession session, boolean created)
{
HttpSessionEvent event=new HttpSessionEvent(session);
for (HttpSessionListener listener : _sessionListeners)
listener.sessionCreated(event);
{
try
{
listener.sessionCreated(event);
}
catch (Throwable t)
{
__log.warn("Error during Session created listener", t);
}
}
}
}
}
Expand Down Expand Up @@ -791,7 +799,14 @@ public boolean removeSession(AbstractSession session, boolean invalidate)
HttpSessionEvent event=new HttpSessionEvent(session);
for (int i = _sessionListeners.size()-1; i>=0; i--)
{
_sessionListeners.get(i).sessionDestroyed(event);
try
{
_sessionListeners.get(i).sessionDestroyed(event);
}
catch(Throwable t)
{
__log.warn("Error during Session destroy listener", t);
}
}
}
}
Expand Down

0 comments on commit 09d74ab

Please sign in to comment.