From 8020fc14161c3c37aec29c338b6c60e75b527d16 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 16 Aug 2017 21:06:23 +0200 Subject: [PATCH] Make IQRequestHandler the only option to handle IQ requests Previously StanzaListeners and Collectors where able to receive IQ of type 'get' or 'set' (i.e., IQ requests) when no IQRequestHandler was registered. By moving the 'return' statement one level down, even listeners/collectors won't receive them. --- .../smack/AbstractXMPPConnection.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 95eea00b6..6d9dc4007 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -1026,12 +1026,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { protected void invokeStanzaCollectorsAndNotifyRecvListeners(final Stanza packet) { if (packet instanceof IQ) { final IQ iq = (IQ) packet; - final IQ.Type type = iq.getType(); - switch (type) { - case set: - case get: + if (iq.isRequestIQ()) { final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace()); IQRequestHandler iqRequestHandler = null; + final IQ.Type type = iq.getType(); switch (type) { case set: synchronized (setIqRequestHandler) { @@ -1102,14 +1100,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } }); - // The following returns makes it impossible for packet listeners and collectors to - // filter for IQ request stanzas, i.e. IQs of type 'set' or 'get'. This is the - // desired behavior. - return; } - break; - default: - break; + // The following returns makes it impossible for packet listeners and collectors to + // filter for IQ request stanzas, i.e. IQs of type 'set' or 'get'. This is the + // desired behavior. + return; } }