Skip to content

Commit

Permalink
Make sure evicted sessions clean up state.
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed May 15, 2017
1 parent c87f2dc commit 4bfcf95
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.openqa.selenium.io.TemporaryFilesystem;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.server.log.LoggingManager;
import org.openqa.selenium.remote.server.log.PerSessionLogHandler;

import java.util.List;
import java.util.ServiceLoader;
Expand Down Expand Up @@ -72,7 +74,14 @@ public DefaultDriverSessions(Platform runningOn, DriverFactory factory, Clock cl
registerDefaults(runningOn);
registerServiceLoaders(runningOn);

RemovalListener<SessionId, Session> listener = notification -> notification.getValue().close();
RemovalListener<SessionId, Session> listener = notification -> {
Session session = notification.getValue();

session.close();
PerSessionLogHandler logHandler = LoggingManager.perSessionLogHandler();
logHandler.transferThreadTempLogsToSessionLogs(session.getSessionId());
logHandler.removeSessionLogs(session.getSessionId());
};

this.sessionIdToDriver = CacheBuilder.newBuilder()
.removalListener(listener)
Expand Down

0 comments on commit 4bfcf95

Please sign in to comment.