mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Improve exception message of XmppConnectionStressTest
This commit is contained in:
parent
fc70484cf6
commit
870756997f
1 changed files with 30 additions and 11 deletions
|
@ -151,18 +151,37 @@ public class XmppConnectionStressTest {
|
|||
|
||||
// Sanity check: All markers before must be true, all markers including the messageNumber marker must be false.
|
||||
for (int i = 0; i < fromMarkers.length; i++) {
|
||||
if ((i < messageNumber && !fromMarkers[i])
|
||||
|| (i >= messageNumber && fromMarkers[i])) {
|
||||
// TODO: Better exception.
|
||||
Exception exception = new Exception("out of order");
|
||||
receiveExceptions.put(connection, exception);
|
||||
// TODO: Current Smack design does not guarantee that the listener won't be invoked again.
|
||||
// This is because the decission to invoke a sync listeners is done at a different place
|
||||
// then invoking the listener.
|
||||
connection.removeSyncStanzaListener(this);
|
||||
receivedSemaphore.release();
|
||||
return;
|
||||
final String inOrderViolation;
|
||||
if (i < messageNumber && !fromMarkers[i]) {
|
||||
// A previous message was missing.
|
||||
inOrderViolation = "not yet message #";
|
||||
} else if (i >= messageNumber && fromMarkers[i]) {
|
||||
// We already received a new message.
|
||||
// TODO: Can it ever happen that this is taken? Wouldn't we prior run into the "a previous
|
||||
// message is missing" case?
|
||||
inOrderViolation = "we already received a later (or the same) message #";
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
StringBuilder exceptionMessage = new StringBuilder();
|
||||
exceptionMessage.append("We received message #").append(messageNumber).append(" but ");
|
||||
exceptionMessage.append(inOrderViolation);
|
||||
exceptionMessage.append(i);
|
||||
exceptionMessage.append("\nMessage with id ").append(stanza.getStanzaId())
|
||||
.append(" from ").append(from)
|
||||
.append(" to ").append(stanza.getTo());
|
||||
|
||||
Exception exception = new Exception(exceptionMessage.toString());
|
||||
receiveExceptions.put(connection, exception);
|
||||
// TODO: Current Smack design does not guarantee that the listener won't be invoked again.
|
||||
// This is because the decission to invoke a sync listeners is done at a different place
|
||||
// then invoking the listener.
|
||||
connection.removeSyncStanzaListener(this);
|
||||
receivedSemaphore.release();
|
||||
// TODO: Do not return here?
|
||||
return;
|
||||
}
|
||||
|
||||
fromMarkers[messageNumber] = true;
|
||||
|
|
Loading…
Reference in a new issue