alut,
Kawajiri Takeshi wrote:
> Hello.
>
> I'm using glassfish-v3-prelude-b28(Grizzly-Comet-1.8.6.1, NetBeans6.5
> Dev 200810041417)
>
> My application have to use multi comet-contexts in a servlet.
> and I want to unregister it when the context has no handlers.
>
> So I wrote CometHandler like this.
> --------------------------------------------------------------------
> public void onInterrupt(CometEvent event) throws IOException {
>
> CometContext context = event.getCometContext();
>
> if (context.getCometHandlers().size() == 1) {
> CometEngine.getEngine().unregister(topic);
> } else {
> context.removeCometHandler(this);
> }
>
> }
> --------------------------------------------------------------------
>
> But when CometEngine#unregister is called,
> all handler(Response) is closed regardless of attaching context.
>
> and a exception occoured
>
> --------------------------------------------------------------------
> CometSelector
> java.lang.IllegalStateException: cometTask cannot be null
> at com.sun.grizzly.comet.CometEngine.interrupt(CometEngine.java:465)
> at com.sun.grizzly.comet.CometSelector.cancelKey(CometSelector.java:273)
> at com.sun.grizzly.comet.CometTask.doTask(CometTask.java:286)
> at com.sun.grizzly.http.TaskBase.call(TaskBase.java:359)
> at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
> at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
> --------------------------------------------------------------------
>
> If I comment out CometEngine#unregister, these don't happen.
Hum...looks like a bug. Are you doing something inside your
onTerminate() method? Because when calling the unregister, Grizzly will
invoke the onTerminate(). I've filled issue:
https://grizzly.dev.java.net/issues/show_bug.cgi?id=281
to improve the documentation that doesn't state that.
> My questions are
>
> (1) Can I use multi contexts?
Yes you should.
> (2) How to unregister context without effect to other contexts ?
>
Can you share a test case? Mainly, it seems the connection get resumed
and at the same time interrupted. I've filled:
https://grizzly.dev.java.net/issues/show_bug.cgi?id=282
because I do think the exception should not be popped. How is you
application after such exception?
Thanks
-- Jeanfrancois
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>