Move nested try block into private method.

This commit is contained in:
akwizgran
2022-05-26 14:54:44 +01:00
parent 94ce6bbb2c
commit 8b61a0279b

View File

@@ -44,6 +44,16 @@ class OwnMailboxConnectivityChecker extends ConnectivityCheckerImpl {
if (!properties.isOwner()) throw new IllegalArgumentException(); if (!properties.isOwner()) throw new IllegalArgumentException();
return () -> { return () -> {
try { try {
return checkConnectivityAndStoreResult(properties);
} catch (DbException e) {
logException(LOG, WARNING, e);
return true; // Retry
}
};
}
private boolean checkConnectivityAndStoreResult(
MailboxProperties properties) throws DbException {
try { try {
mailboxApi.getFolders(properties); mailboxApi.getFolders(properties);
LOG.info("Own mailbox is reachable"); LOG.info("Own mailbox is reachable");
@@ -60,11 +70,6 @@ class OwnMailboxConnectivityChecker extends ConnectivityCheckerImpl {
db.transaction(false, txn -> mailboxSettingsManager db.transaction(false, txn -> mailboxSettingsManager
.recordFailedConnectionAttempt(txn, now)); .recordFailedConnectionAttempt(txn, now));
} }
} catch (DbException e) {
logException(LOG, WARNING, e);
}
return true; // Retry return true; // Retry
};
} }
} }