Hello everybody,
Today a coworker found out a bug. If two users log in, they can send each other messages. If one of the users logs out and the other one tries to send him a message, the message is still caught in the onMessage() method from the ITopicSubscriber which results in a NPE thrown by template.executeAsynch(callback) because the desktop is null after the first user logged out.
I already tried to unsubscribe the DashboardPanel in the onPageDetached() method with the following code but it didn't work:
IMessageService service = Service.locator().locate(IMessageService.class).getService();
if (service != null) {
ITopic<Map<String, Integer>> intopic = service.getTopic(ON_USER_LOGGED_IN_TOPIC);
intopic.unsubscribe(this);
}
I wonder what i am doing wrong. What should i do to stop my DashboardPanel from receiving messages?
I saw that in DPRecentItems, there are also some other things i don't use yet:
- org.zkoss.zk.ui.util.DesktopCleanup
- org.osgi.service.event.EventHandler
- org.osgi.service.event.Event
- java.lang.ref.WeakReference
- (custom) TopicSubscriber
Do i need to use all the classes above so that i don't get exceptions from "dead" DashboardPanels? Do i need to use it in the same way it is used in DPRecentItems or are there other ways of doing it?
I hope you can help me.