Try to close connection if contact exchange fails.

This commit is contained in:
akwizgran
2019-05-24 13:14:53 +01:00
parent f1e5c2dd66
commit d80c77f466

View File

@@ -66,15 +66,26 @@ class ContactExchangeViewModel extends AndroidViewModel {
remoteAuthor = contact.getAuthor();
succeeded.postValue(true);
} catch (ContactExistsException e) {
tryToClose(conn);
duplicateAuthor = e.getRemoteAuthor();
succeeded.postValue(false);
} catch (DbException | IOException e) {
tryToClose(conn);
logException(LOG, WARNING, e);
succeeded.postValue(false);
}
});
}
private void tryToClose(DuplexTransportConnection conn) {
try {
conn.getReader().dispose(true, true);
conn.getWriter().dispose(true);
} catch (IOException e) {
logException(LOG, WARNING, e);
}
}
@UiThread
@Nullable
Author getRemoteAuthor() {