mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Unify introduction response methods and handle ProtocolStateException
It is possible that a remote DECLINE message arrives short before the user responds to the introduction. This will cause a ProtocolStateException which (for now) is just caught and a generic (existing) error message will be shown.
This commit is contained in:
@@ -339,18 +339,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException {
|
||||
respondToRequest(contactId, sessionId, timestamp, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declineIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp) throws DbException {
|
||||
respondToRequest(contactId, sessionId, timestamp, false);
|
||||
}
|
||||
|
||||
private void respondToRequest(ContactId contactId, SessionId sessionId,
|
||||
public void respondToIntroduction(ContactId contactId, SessionId sessionId,
|
||||
long timestamp, boolean accept) throws DbException {
|
||||
Transaction txn = db.startTransaction(false);
|
||||
try {
|
||||
|
||||
@@ -445,7 +445,8 @@ public class IntroductionIntegrationTest
|
||||
|
||||
// answer request manually
|
||||
introductionManager2
|
||||
.acceptIntroduction(contactId0From2, listener2.sessionId, time);
|
||||
.respondToIntroduction(contactId0From2, listener2.sessionId, time,
|
||||
true);
|
||||
|
||||
// sync second response and ACK and make sure there is no abort
|
||||
sync2To0(2, true);
|
||||
@@ -1003,25 +1004,13 @@ public class IntroductionIntegrationTest
|
||||
long time = clock.currentTimeMillis();
|
||||
try {
|
||||
if (introducee == 1 && answerRequests) {
|
||||
if (accept) {
|
||||
introductionManager1
|
||||
.acceptIntroduction(contactId, sessionId,
|
||||
time);
|
||||
} else {
|
||||
introductionManager1
|
||||
.declineIntroduction(contactId, sessionId,
|
||||
time);
|
||||
}
|
||||
introductionManager1
|
||||
.respondToIntroduction(contactId, sessionId,
|
||||
time, accept);
|
||||
} else if (introducee == 2 && answerRequests) {
|
||||
if (accept) {
|
||||
introductionManager2
|
||||
.acceptIntroduction(contactId, sessionId,
|
||||
time);
|
||||
} else {
|
||||
introductionManager2
|
||||
.declineIntroduction(contactId, sessionId,
|
||||
time);
|
||||
}
|
||||
introductionManager2
|
||||
.respondToIntroduction(contactId, sessionId,
|
||||
time, accept);
|
||||
}
|
||||
} catch (DbException exception) {
|
||||
eventWaiter.rethrow(exception);
|
||||
|
||||
Reference in New Issue
Block a user