Commit c535348c authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed NPE when processing IQ roster packet of a closed session. JM-538

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3351 b35dd754-fafc-0310-a699-88a17e54d16e
parent a03fcc49
...@@ -164,23 +164,27 @@ public class IQRosterHandler extends IQHandler implements ServerFeaturesProvider ...@@ -164,23 +164,27 @@ public class IQRosterHandler extends IQHandler implements ServerFeaturesProvider
UserAlreadyExistsException, SharedGroupException { UserAlreadyExistsException, SharedGroupException {
IQ returnPacket = null; IQ returnPacket = null;
ClientSession session = sessionManager.getSession(packet.getFrom()); JID sender = packet.getFrom();
IQ.Type type = packet.getType(); IQ.Type type = packet.getType();
try { try {
if (session.getUsername() == null && IQ.Type.get == type) { if (sender.getNode() == null && IQ.Type.get == type) {
// If anonymous user asks for his roster then return an empty roster // If anonymous user asks for his roster then return an empty roster
IQ reply = IQ.createResultIQ(packet); IQ reply = IQ.createResultIQ(packet);
reply.setChildElement("query", "jabber:iq:roster"); reply.setChildElement("query", "jabber:iq:roster");
return reply; return reply;
} }
User sessionUser = userManager.getUser(session.getUsername()); if (!localServer.isLocal(sender)) {
Roster cachedRoster = sessionUser.getRoster(); // Sender belongs to a remote server so discard this IQ request
Log.warn("Discarding IQ roster packet of remote user: " + packet);
return null;
}
Roster cachedRoster = userManager.getUser(sender.getNode()).getRoster();
if (IQ.Type.get == type) { if (IQ.Type.get == type) {
returnPacket = cachedRoster.getReset(); returnPacket = cachedRoster.getReset();
returnPacket.setType(IQ.Type.result); returnPacket.setType(IQ.Type.result);
returnPacket.setTo(session.getAddress()); returnPacket.setTo(sender);
returnPacket.setID(packet.getID()); returnPacket.setID(packet.getID());
// Force delivery of the response because we need to trigger // Force delivery of the response because we need to trigger
// a presence probe from all contacts // a presence probe from all contacts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment