mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-20 17:47:57 +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)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException,
|
||||
InterruptedException {
|
||||
throws InterruptedException, XMPPException, SmackException, IOException {
|
||||
if (config.registerAccounts) {
|
||||
final int maxAttempts = 3;
|
||||
AccountManager am = AccountManager.getInstance(connection);
|
||||
am.deleteAccount();
|
||||
int attempts;
|
||||
for (attempts = 0; attempts < maxAttempts; attempts++) {
|
||||
try {
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue