From 5b137616bbdd5e0ec21d09e3b271f50612f226bd Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 31 Jul 2016 14:30:23 +0200 Subject: [PATCH] Fix NPE in IoTDiscoveryManager --- .../smackx/iot/discovery/IoTDiscoveryManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java index 8851f84e1..f1ce9c362 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java @@ -36,6 +36,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.iot.Thing; @@ -202,7 +203,7 @@ public final class IoTDiscoveryManager extends Manager { /** * Try to find an XMPP IoT registry. * - * @return the JID of a Thing Registry if one could be found. + * @return the JID of a Thing Registry if one could be found, null otherwise. * @throws InterruptedException * @throws NotConnectedException * @throws XMPPErrorException @@ -373,9 +374,11 @@ public final class IoTDiscoveryManager extends Manager { // Registry utility methods public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { + Objects.requireNonNull(jid, "JID argument must not be null"); // At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is // not the case from the beginning, we perform findRegistry().equals(jid) too. - if (findRegistry().equals(jid)) { + Jid registry = findRegistry(); + if (jid.equals(registry)) { return true; } if (usedRegistries.contains(jid)) {