Skip to content

Commit

Permalink
[sinttest] Do not leak stanza listener in MultiUserChatOccupantIntegr…
Browse files Browse the repository at this point in the history
…ationTest
  • Loading branch information
Flowdalic committed Jun 27, 2024
1 parent c322ce8 commit d27fef0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.jivesoftware.smack.PresenceListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.packet.Message;
Expand Down Expand Up @@ -107,12 +108,13 @@ public void mucJoinEventOrderingTest() throws Exception {

final ResultSyncPoint<String, Exception> subjectResultSyncPoint = new ResultSyncPoint<>();
final List<Stanza> results = new ArrayList<>();
conTwo.addStanzaListener(stanza -> {
final StanzaListener stanzaListener = stanza -> {
results.add(stanza);
if (stanza instanceof Message && ((Message) stanza).getSubject() != null) {
subjectResultSyncPoint.signal(((Message) stanza).getSubject());
}
}, FromMatchesFilter.create(mucAddress));
};
conTwo.addStanzaListener(stanzaListener, FromMatchesFilter.create(mucAddress));

try {
mucAsSeenByTwo.join(nicknameTwo);
Expand All @@ -130,6 +132,7 @@ public void mucJoinEventOrderingTest() throws Exception {
assertEquals(mucSubject, ((Message) results.get(3)).getSubject(), "The fourth stanza that was received by '" + conTwo.getUser() + "' after it joined room '" + mucAddress + "' was expected to be a different stanza.");
} finally {
tryDestroy(mucAsSeenByOne);
conTwo.removeStanzaListener(stanzaListener);
}
}

Expand Down

0 comments on commit d27fef0

Please sign in to comment.