mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +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,19 +151,38 @@ public class XmppConnectionStressTest {
|
||||||
|
|
||||||
// Sanity check: All markers before must be true, all markers including the messageNumber marker must be false.
|
// 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++) {
|
for (int i = 0; i < fromMarkers.length; i++) {
|
||||||
if ((i < messageNumber && !fromMarkers[i])
|
final String inOrderViolation;
|
||||||
|| (i >= messageNumber && fromMarkers[i])) {
|
if (i < messageNumber && !fromMarkers[i]) {
|
||||||
// TODO: Better exception.
|
// A previous message was missing.
|
||||||
Exception exception = new Exception("out of order");
|
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);
|
receiveExceptions.put(connection, exception);
|
||||||
// TODO: Current Smack design does not guarantee that the listener won't be invoked again.
|
// 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
|
// This is because the decission to invoke a sync listeners is done at a different place
|
||||||
// then invoking the listener.
|
// then invoking the listener.
|
||||||
connection.removeSyncStanzaListener(this);
|
connection.removeSyncStanzaListener(this);
|
||||||
receivedSemaphore.release();
|
receivedSemaphore.release();
|
||||||
|
// TODO: Do not return here?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fromMarkers[messageNumber] = true;
|
fromMarkers[messageNumber] = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue