mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 11:47:01 +00:00
SPARK-2349: fix NPE when adding yourself to contact list
In this case you'll get the presence from PresenceManager constants that doesn't have the from field. This make a two NPEs.
This commit is contained in:
parent
dc0f625f25
commit
443f6441fb
@ -316,6 +316,9 @@ public class ContactList extends JPanel implements ActionListener,
|
||||
// We ignore this.
|
||||
return;
|
||||
}
|
||||
if (presence.getFrom() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Roster roster = Roster.getInstanceFor(SparkManager.getConnection());
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@ -285,7 +286,11 @@ public class GatewayPlugin implements Plugin, ContactItemHandler {
|
||||
@Override
|
||||
public boolean handlePresence(ContactItem item, Presence presence) {
|
||||
if (presence.isAvailable()) {
|
||||
DomainBareJid domain = presence.getFrom().asDomainBareJid();
|
||||
Jid from = presence.getFrom();
|
||||
if (from == null) {
|
||||
return false;
|
||||
}
|
||||
DomainBareJid domain = from.asDomainBareJid();
|
||||
Transport transport = TransportUtils.getTransport(domain);
|
||||
if (transport != null) {
|
||||
if (presence.getType() == Presence.Type.available) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user