ChatManager keeps track of chats in a case-sensitive map, which can cause issues for applications where the jabber credentials may be fetched from another source, such as a support or personnel database, if that source has different cases than the jabber server. When a Chat is created, ChatManager will create and track it using:
Chat chat = new Chat(this, userJID, threadID); this.threadChats.put(threadID, chat); this.jidChats.put(userJID, chat); this.baseJidChats.put(StringUtils.parseBareAddress(userJID), chat);
So, if our application initiates a chat from FirstNameLastName@domain.org, we have maps like this pseudo-json:
When the server responds to email@example.com, chat1 will not be found in the maps. A new chat is created, so our map becomes:
The message will appear to the server to be delivered, but the application using smack will not see the response, because the response goes to chat2 and its MessageListener, not to chat1.
It appears that nodes should be compared in “case-normalized canonical form”, domains are case-inensitive, and resources are case-sensitive, but the maps in ChatManager do not behave that way. Is this a bug in smack, or do applications need to consult the Presence roster and normalize cases themselves before initiating any chat?