Skip to content

Commit

Permalink
Merge pull request #6948 from eclipse/jetty-9.3.x-backport-session-li…
Browse files Browse the repository at this point in the history
…stener-fix

Issue #6277 - Protect from Throwables on HttpSessionListener events.
  • Loading branch information
joakime authored Oct 1, 2021
2 parents 1846b28 + 09d74ab commit 791d9d1
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
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 791d9d1

Please sign in to comment.