mirror of
https://github.com/Qortal/qortal.git
synced 2025-06-07 16:56:59 +00:00
Give up after 5 attempts to request data in the GET /arbitrary APIs
This commit is contained in:
parent
fead482b0d
commit
3b5b45b463
@ -464,12 +464,19 @@ public class ArbitraryResource {
|
|||||||
ArbitraryDataReader arbitraryDataReader = new ArbitraryDataReader(name, ArbitraryDataFile.ResourceIdType.NAME, service, identifier);
|
ArbitraryDataReader arbitraryDataReader = new ArbitraryDataReader(name, ArbitraryDataFile.ResourceIdType.NAME, service, identifier);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
int attempts = 0;
|
||||||
|
|
||||||
// Loop until we have data
|
// Loop until we have data
|
||||||
while (!Controller.isStopping()) {
|
while (!Controller.isStopping()) {
|
||||||
|
attempts++;
|
||||||
try {
|
try {
|
||||||
arbitraryDataReader.loadSynchronously(rebuild);
|
arbitraryDataReader.loadSynchronously(rebuild);
|
||||||
break;
|
break;
|
||||||
} catch (MissingDataException e) {
|
} 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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user