PEP Messages Stored Offline in 3.8.2

Hi Everyone,

I’m currently in the process of configuring Openfire 3.8.2 on a new server, with a view to migrating my existing 3.6.4 server across. While checking compatibility with the XMPP clients using our system I noticed that PEP messages are now being stored in the offline message table. From what I have seen in the pubsub spec and the source code comments this shouldn’t happen (and didn’t appear to happen in 3.6.4).

I have been digging around in the code and I think I have narrowed down where the problem is. In PEPService.java - sendNotification() the recipientFullJIDs list is only populated if the recipientJID resource is null and there are some resources online (for local users). If no resources are online, the recipientFullJIDs list is empty and the message is sent to the router anyway. This code appears to be the same in 3.6.4, so I’m not sure why it is now a problem in 3.8.2. I have made the following changes, which seem to have solved the problem for me.

<JID> recipientFullJIDs = new HashSet****<JID>();
if (XMPPServer.getInstance().isLocal(recipientJID)) {
**** if
(recipientJID.getResource() == null) {
**** for**** (ClientSession clientSession : SessionManager.getInstance().getSessions(recipientJID.getNode())) {
recipientFullJIDs.add(clientSession.getAddress());
}
}

Set

 /* new code starts */    

**** else**** {
** // check that the resource is actually online, otherwise the message will end up in offline storage
****** if**** (SessionManager.getInstance().getSession(recipientJID) != null) {
recipientFullJIDs.add(recipientJID);
}
}

/* new code ends */    

}
else {
** // Since recipientJID is not local, try to get presence info from cached known remote
**** // presences.
**
** // TODO: OF-605 the old code depends on a cache that would contain presence state on all (?!) JIDS on all (?!)
**** // remote domains. As we cannot depend on this information to be correct (even if we could ensure that this
**** // potentially unlimited amount of data would indeed be manageable in the first place), this code was removed.
**
recipientFullJIDs.add(recipientJID);
}

if (recipientFullJIDs.isEmpty()) {

/* removed this line as it is not needed any more - if the list is empty, don’t route the message anywhere /
** // router.route(message);
****** return
***;
}

Is this a sensible change, or am I missing something? (very possible as I’m not a Java developer by trade, and this is my first dig around in the server code)

Any ideas why this wasn’t a problem in 3.6.4?

Thanks for your help.

Baz