Browse Source

Give up after 5 attempts to request data in the GET /arbitrary APIs

qdn
CalDescent 3 years ago
parent
commit
3b5b45b463
  1. 7
      src/main/java/org/qortal/api/resource/ArbitraryResource.java

7
src/main/java/org/qortal/api/resource/ArbitraryResource.java

@ -464,12 +464,19 @@ public class ArbitraryResource {
ArbitraryDataReader arbitraryDataReader = new ArbitraryDataReader(name, ArbitraryDataFile.ResourceIdType.NAME, service, identifier);
try {
int attempts = 0;
// Loop until we have data
while (!Controller.isStopping()) {
attempts++;
try {
arbitraryDataReader.loadSynchronously(rebuild);
break;
} catch (MissingDataException e) {
if (attempts > 5) {
// Give up after 5 attempts
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.INVALID_CRITERIA, "Data unavailable. Please try again later.");
}
continue;
}
}

Loading…
Cancel
Save