1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

[sinttest] Fix race condition in MUC test

When occupant One waits for occupant Two to join the room, One should register the corresponding listener _before_ Two joins.

Without this, a race conditions occurs, where Two could have joined the room before One registered the listener, thus missing the event.
This commit is contained in:
Guus der Kinderen 2024-06-13 15:26:42 +02:00
parent 4f09244253
commit adafcdb6d1

View file

@ -214,16 +214,15 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
final Resourcepart nicknameThree = Resourcepart.from("three-" + randomString);
createMuc(mucAsSeenByOne, nicknameOne);
mucAsSeenByTwo.join(nicknameTwo);
SimpleResultSyncPoint oneSeesTwo = new SimpleResultSyncPoint();
mucAsSeenByOne.addParticipantListener(presence -> {
if (nicknameTwo.equals(presence.getFrom().getResourceOrEmpty())) {
oneSeesTwo.signal();
}
});
mucAsSeenByOne.grantModerator(nicknameTwo);
mucAsSeenByTwo.join(nicknameTwo);
oneSeesTwo.waitForResult(timeout);
mucAsSeenByOne.grantModerator(nicknameTwo);
List<Presence> results = new ArrayList<>();
mucAsSeenByThree.addParticipantListener(results::add);