mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 08:12:05 +01:00
Retry to delete integration test accounts
in the the connection was terminated because of an error, try to re-establish the connection when trying to delete the account.
This commit is contained in:
parent
f274581c27
commit
bfb3f5cd95
1 changed files with 19 additions and 3 deletions
|
@ -466,11 +466,27 @@ public class SmackIntegrationTestFramework {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void disconnectAndMaybeDelete(XMPPTCPConnection connection)
|
protected void disconnectAndMaybeDelete(XMPPTCPConnection connection)
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException,
|
throws InterruptedException, XMPPException, SmackException, IOException {
|
||||||
InterruptedException {
|
|
||||||
if (config.registerAccounts) {
|
if (config.registerAccounts) {
|
||||||
|
final int maxAttempts = 3;
|
||||||
AccountManager am = AccountManager.getInstance(connection);
|
AccountManager am = AccountManager.getInstance(connection);
|
||||||
|
int attempts;
|
||||||
|
for (attempts = 0; attempts < maxAttempts; attempts++) {
|
||||||
|
try {
|
||||||
am.deleteAccount();
|
am.deleteAccount();
|
||||||
|
} catch (NoResponseException | InterruptedException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Exception deleting account" , e);
|
||||||
|
continue;
|
||||||
|
} catch (NotConnectedException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Exception deleting account" , e);
|
||||||
|
connection.connect().login();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (attempts > maxAttempts) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not delete account for connection: " + connection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue