Patch proposal, Roster class, bug correction

In smack 3.0.4, error presence packets like this are not handled:

This happens when a server is down.

But the Roster doesn’t process these packets so we have the wrong Presence when asking the Roster about the user.

Here is my attached patch:

Index: org/jivesoftware/smack/Roster.java

— org/jivesoftware/smack/Roster.java (révision 803)
+++ org/jivesoftware/smack/Roster.java (révision 804)
@@ -733,6 +733,30 @@
}
// Otherwise, in manual mode so ignore.
}

  •        else if (presence.getType() == Presence.Type.error && "".equals(StringUtils.parseResource(from))) {
    
  •            // error packet with bareJID from: the server is in error
    
  •            // we don't care of the detailed message
    
  •            // Get the user presence map
    
  •            Map<String, Presence> userPresences;
    
  •            if (!presenceMap.containsKey(key)) {
    
  •                // create a new one because there isn't any
    
  •                userPresences = new ConcurrentHashMap<String, Presence>();
    
  •                presenceMap.put(key, userPresences);
    
  •            }
    
  •            else {
    
  •                userPresences = presenceMap.get(key);
    
  •                // clear presences, they are invalidated by this error packet
    
  •                userPresences.clear();
    
  •            }
    
  •            // Add the new presence, using the empty resource as a key.
    
  •            userPresences.put("", presence);
    
  •            // If the user is in the roster, fire an event.
    
  •            for (RosterEntry entry : entries) {
    
  •                if (entry.getUser().equals(key)) {
    
  •                    fireRosterPresenceEvent(presence);
    
  •                }
    
  •            }
    
  •        }
       }
    
    }
    roster.patch (1621 Bytes)

I see this bug has not been fixed in 3.1.0 beta 1, please consider this thread.

hi,

I filed this in Jira, so that Matt hopefully sees it:

http://www.igniterealtime.org/issues/browse/SMACK-260

daryl

Thanks !