I’m trying Smack 3.1.0, and I’m quite impressed, making a jabber rhino REPL in something like half hour.
However, I’ve found a bug which took a few hours to figure out:
If the remote client doesn’t supply a thread-id (psi doesn’t), then Smack will create a new Chat for every thread. It can’t ever reuse chats from ChatManager.jidChats because of an impedance mismatch.
The problem is, it puts raw jabber addresses as keys (foo@bar.org/Client), but gets jabber addresses cleaned by StringUtils.parseBareAddress (foo@bar.org)
The following patch fixes the problem:
`--- ../smack_src_3_1_0/source/org/jivesoftware/smack/ChatManager.java 2008-11-21 08:31:48 +0300
+++ source/org/jivesoftware/smack/ChatManager.java 2009-01-22 17:30:49 +0300
@@ -102,13 +102,13 @@
Message message = (Message) packet;
Chat chat;
if (message.getThread() == null) {
- chat = getUserChat(StringUtils.parseBareAddress(message.getFrom()));
+ chat = getUserChat(message.getFrom());
}
else {
chat = getThreadChat(message.getThread());
if (chat == null) {
// Try to locate the chat based on the sender of the message
- chat = getUserChat(StringUtils.parseBareAddress(message.getFrom()));
+ chat = getUserChat(message.getFrom());
}
} `
P.S. The HTML editor is kind of creepy, having no fallback to plain HTML. It doesn’t work in Konqueror at all, so I had to fire Firefox
According to the JIRA instance for smack http://www.igniterealtime.org/issues/browse/SMACK you should post bugs here on the forums and a developer will create a JIRA issue. This does not seem to be happening.
I had a look, and found that the original code is most likely to match the bare JID against full JIDs in a map. This makes getting successful matches more unlikely. I’ve applied the patch to Smacks trunk. It will be part of the next release.
With the patch that you have applied there is a problem if smack creates a chat for a user with a bare jid user@server.com. If the user replies without a thread id and a full jid in the from attribute user@server.com/res, a new chat will be created. Smack should check if a a chat with the bare jid exists and deliver the message to it.