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:
Torsten Grote
2021-12-15 16:54:04 -03:00
parent d665fc17ec
commit 9f1757ccaf
3 changed files with 16 additions and 47 deletions

View File

@@ -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;
}
}
}

View File

@@ -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();
}