mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Remove concept of fatal permanent exceptions
All exceptions will just cause the request to be tried again with some backoff.
This commit is contained in:
@@ -40,14 +40,5 @@ interface MailboxApi {
|
||||
|
||||
@Immutable
|
||||
class PermanentFailureException extends Exception {
|
||||
/**
|
||||
* If true, the failure is fatal and requires user attention.
|
||||
* The entire task queue will most likely need to stop.
|
||||
*/
|
||||
final boolean fatal;
|
||||
|
||||
PermanentFailureException(boolean fatal) {
|
||||
this.fatal = fatal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,25 +42,23 @@ class MailboxApiImpl implements MailboxApi {
|
||||
.build();
|
||||
OkHttpClient client = httpClientProvider.get();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.code() == 401) {
|
||||
throw new PermanentFailureException(true);
|
||||
}
|
||||
if (response.code() == 401) throw new PermanentFailureException();
|
||||
if (!response.isSuccessful()) throw new IOException();
|
||||
ResponseBody body = response.body();
|
||||
if (body == null) throw new PermanentFailureException(false);
|
||||
if (body == null) throw new PermanentFailureException();
|
||||
try {
|
||||
JsonNode node = mapper.readTree(body.string());
|
||||
JsonNode tokenNode = node.get("token");
|
||||
if (tokenNode == null) {
|
||||
throw new PermanentFailureException(false);
|
||||
throw new PermanentFailureException();
|
||||
}
|
||||
String ownerToken = tokenNode.textValue();
|
||||
if (ownerToken == null) {
|
||||
throw new PermanentFailureException(false);
|
||||
throw new PermanentFailureException();
|
||||
}
|
||||
return ownerToken;
|
||||
} catch (JacksonException e) {
|
||||
throw new PermanentFailureException(false);
|
||||
throw new PermanentFailureException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +71,7 @@ class MailboxApiImpl implements MailboxApi {
|
||||
.build();
|
||||
OkHttpClient client = httpClientProvider.get();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.code() == 401) {
|
||||
throw new PermanentFailureException(true);
|
||||
}
|
||||
if (response.code() == 401) throw new PermanentFailureException();
|
||||
return response.isSuccessful();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user