From 54790cd3807204ebaba2bbea9966554b5d5f20c4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 10 Nov 2016 14:57:01 +0100 Subject: [PATCH] Filter MUC 'decline' messages by type 'normal' and not by '!error' as this there are presence stanzas containing the muc#user namespace also send to the client, which results in a ClassCastException in the StanzaListener. --- .../java/org/jivesoftware/smackx/muc/MultiUserChat.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index b0e759a9b..d8fdd10b4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -135,6 +135,9 @@ public class MultiUserChat { private final StanzaListener messageListener; private final StanzaListener presenceListener; private final StanzaListener subjectListener; + + private static final StanzaFilter DECLINE_FILTER = new AndFilter(MessageTypeFilter.NORMAL, + new StanzaExtensionFilter(MUCUser.ELEMENT, MUCUser.NAMESPACE)); private final StanzaListener declinesListener; private String subject; @@ -317,8 +320,7 @@ public class MultiUserChat { StanzaTypeFilter.PRESENCE)); connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter, MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR))); - connection.addSyncStanzaListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT, - MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR))); + connection.addSyncStanzaListener(declinesListener, DECLINE_FILTER); connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room), StanzaTypeFilter.PRESENCE)); messageCollector = connection.createPacketCollector(fromRoomGroupchatFilter);