-
Bug
-
Resolution: Done
-
Blocker
-
4.0.0.Final
In our application, we're seeing run-away threads when using the ObservationManager. Our application creates a new session for every HTTP request, and uses the ObservationManager to register some contextual data. When we invoke Workspace#getObservationManager, it appears that we create a new modeshape-event-dispatcher thread that is not disposed off when Session#logout is called.
Not that this is a very good demo, but I hope it gets the point across:
@Test @FixFor("MODE-xxxx") public void shouldNotLeakObservers() throws Exception { final int oldCount = Thread.activeCount(); for (int i = 0; i < 1000; i++) { final Session newSession = newSession(); newSession.getWorkspace().getObservationManager(); newSession.logout(); } final int newCount = Thread.activeCount(); assertEquals(oldCount, newCount); /* After running the test, these counts are ~1000 different */ }
Digging into the code, I suspect (though haven't confirmed) that the ObservationManager's own listener is not removed:
- is related to
-
MODE-2345 Improve statistics for events
- Resolved