485064 HashSessionManager leaks ScheduledExecutorScheduler with reference to un-deployed webapp

This commit is contained in:
Jan Bartel 2016-01-06 11:22:18 +11:00
parent f519aa28fb
commit 913ef1a39a
2 changed files with 26 additions and 3 deletions

View File

@ -184,6 +184,11 @@ public class HashSessionManager extends AbstractSessionManager
_task.cancel();
_task=null;
//if we're managing our own timer, remove it
if (isManaged(_timer))
removeBean(_timer);
_timer=null;
}
@ -192,7 +197,6 @@ public class HashSessionManager extends AbstractSessionManager
super.doStop();
_sessions.clear();
}
/* ------------------------------------------------------------ */

View File

@ -25,6 +25,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.thread.Scheduler;
import org.junit.Assert;
import org.junit.Test;
@ -80,7 +81,25 @@ public class HashSessionManagerTest
Server server = new Server();
SessionHandler handler = new SessionHandler();
handler.setServer(server);
HashSessionManager manager = new HashSessionManager();
HashSessionManager manager = new HashSessionManager()
{
@Override
public void doStart() throws Exception
{
super.doStart();
Scheduler timerBean = getBean(Scheduler.class);
Assert.assertNotNull(timerBean);
}
@Override
public void doStop() throws Exception
{
super.doStop();
Scheduler timerBean = getBean(Scheduler.class);
Assert.assertNull(timerBean);
}
};
manager.setStoreDirectory(testDir);
manager.setMaxInactiveInterval(5);
Assert.assertTrue(testDir.exists());