Smack 3.1.0 creates a new chat for every incoming message

Description

Smack 3.1.0 creates a new chat for every incoming message

Forum Post Quote:
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)

FIX is described here:
http://www.igniterealtime.org/community/message/189614

Environment

None

Activity

Show:

Robin Collier February 21, 2011 at 7:01 PM

Added tracking of chats by base jid (only full jid currently). Now when a chat message with no thread id is received, a match is attempted by both full and base jid, thus insuring a match if a chat to that user has already been created. Also made the lookups threadsafe.

On a different note though, I noticed that it also attempts to do this same match when there is a thread ID as well but no existing chat exists for that ID. I would think that should always result in a new chat, not matching a chat with a different id but the same JID, which is what it does now.

Guus der Kinderen February 24, 2010 at 8:48 PM

Guus der Kinderen January 12, 2010 at 5:33 AM

The unpatched source matches the bare JIDs against a map that is most likely to hold full JIDs. I've applied the patch as provided in the community discussion.

Konrad Mrożek August 6, 2009 at 1:40 PM

Hi, I think the patch which was given is sufficient. It corrects the bug. Why isn't it commited to trunk?

ThreadID is a problem for e.g. Psi or iChat. These programs don't attach threadid to message "chat" packet at all. So someone (as I have seen in SVN called gato) added workaround to this bug of clients. But he probably didn't think about resources attached address or didn't change line 177 to

String userJID = StringUtils.parseBareAddress(message.getFrom());

I think, that patch from ilja makes assigning chats without threadid more accurate.

So I don't know why it's not commited yet.

Ankit Nitin July 14, 2009 at 6:24 PM

Major problem
--------------------
ThreadID is everywhere documented as the unique identifier for chat messages. If a packet do not contain a threadID then how smack figure out the chat object to which the packet needs to be delivered ?

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created April 7, 2009 at 11:50 PM
Updated February 1, 2014 at 3:31 PM
Resolved February 21, 2011 at 7:03 PM

Flag notifications