Growing number of broadcaster threads
I create a new broadcaster with a unique ID for every new client. I track clients by saving a cookie with broadcaster ID. I programmatically set up shared thread pools for every new broadcaster, as per the wiki guide.
broadcasterLifeCyclePolicy is set to IDLE_DESTROY in web.xml, with idle time 35000 ms.
The problem is, as new clients connect, there is constantly a growing number of threads that never get removed, even when clients disconnect and idle timeout expires.
Thread dump shows hundreds of threads with names like pool-21426-thread-1 that are waiting indefinitely.
I use Jersey, long-polling transport, glassfish 3.1.2.2, latest snapshot of atmosphere.
There was no issue with atmosphere 1.0.2
@nite23 Which version are you using to reproduce the issue? Also please attach the thread dump if you can. Thanks
@nite23 To be more specific, you use 1.1.0-SNAPSHOT or 1.0.3-SNAPSHOT?
I use 1.1.0-SNAPSHOT
here's the dump: http://files.internetplus.cz/dump.txt
OK, I fail to reproduce this issue using 1.1-SNAPSHOT and this test case:
@Test
public void testBroadcasterEmptyDestroy() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Boolean> deleted = new AtomicReference<Boolean>();
BroadcasterListener l = new BroadcasterListener() {
@Override
public void onPostCreate(Broadcaster b) {
}
@Override
public void onComplete(Broadcaster b) {
}
@Override
public void onPreDestroy(Broadcaster b) {
deleted.set(Boolean.TRUE);
latch.countDown();
}
};
BroadcasterFactory.getDefault().addBroadcasterListener(l).get("/b1")
.setBroadcasterLifeCyclePolicy(new BroadcasterLifeCyclePolicy.Builder()
.policy(BroadcasterLifeCyclePolicy.ATMOSPHERE_RESOURCE_POLICY.IDLE_DESTROY)
.idleTime(5, TimeUnit.SECONDS).build());
latch.await(10, TimeUnit.SECONDS);
assertTrue(deleted.get());
}
Fixed by #717