1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02:00

Rename waitForCondition() to waitForConditionOrConnectionException()

To make it clear that this will either return if the condition is
true *or* if a connection exception happened.

Also introduce waitFor(), which is deliberately not named
waitForCondition() because it carries a different semantic.
This commit is contained in:
Florian Schmaus 2020-06-17 20:27:02 +02:00
parent f9292a23fb
commit ddc39030d7
2 changed files with 12 additions and 8 deletions

View file

@ -394,7 +394,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (isSmResumptionPossible()) {
smResumedSyncPoint = SyncPointState.request_sent;
sendNonza(new Resume(clientHandledStanzasCount, smSessionId));
waitForCondition(() -> smResumedSyncPoint == SyncPointState.successful || smResumptionFailed != null, "resume previous stream");
waitForConditionOrConnectionException(() -> smResumedSyncPoint == SyncPointState.successful || smResumptionFailed != null, "resume previous stream");
if (smResumedSyncPoint == SyncPointState.successful) {
// We successfully resumed the stream, be done here
afterSuccessfulLogin(true);
@ -518,7 +518,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
setWasAuthenticated();
try {
boolean readerAndWriterThreadsTermianted = waitForCondition(() -> !packetWriter.running && !packetReader.running);
boolean readerAndWriterThreadsTermianted = waitForConditionOrConnectionException(() -> !packetWriter.running && !packetReader.running);
if (!readerAndWriterThreadsTermianted) {
LOGGER.severe("Reader and/or writer threads did not terminate timely. Writer running: "
+ packetWriter.running + ", Reader running: " + packetReader.running);