NullPointerException with Pubsub(PEP?) and clustering
I'm not sure if the problem is limited to the following scenario, or if the problem can be reproduced.
Running on a two-node cluster, Openfire 4.6.0 Alpha, Hazelcast plugin 2.5.0
A user logged in on the junior cluster node
On the senior cluster node, this NullPointerException was logged a couple of times in rapid succession (four times in two seconds):
I can reproduce this pretty easily on Master, but not on the branch.
Have a user on both nodes subscribe to a PubSub node
That’s it. That’s the test.
Have looked at Pubsub, PEP, single servers and clustered operations.
This problem is caused by an oversight in the implementation in various cluster tasks. A cluster task is primarily intended to update the in-memory representation of an entity that was modified on the cluster node that originates the task (it’s somewhat of a clean-up action). As such, it is often not needed to perform actions, when the entity that it relates to isn’t loaded in memory of a particular node. The implementation of various tasks provide methods that would return such entities, only when they were loaded in memory. Consumers of those methods sometimes assume that an instance would be returned no matter what, causing the nullpointer exceptions.
Apart from fixing the code, intent should be expressed better, by renaming methods and providing better documentation.