Merge pull request #4963 from chimp1984/fix-case-if-no-data-store-service-is-available

Call completeHandler if services in store services is empty.
This commit is contained in:
sqrrm 2020-12-17 00:55:26 +01:00 committed by GitHub
commit 113bb4f7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View File

@ -209,13 +209,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
BooleanProperty protectedDataStoreServiceReady = new SimpleBooleanProperty();
BooleanProperty resourceDataStoreServiceReady = new SimpleBooleanProperty();
appendOnlyDataStoreService.readFromResources(postFix, () -> appendOnlyDataStoreServiceReady.set(true));
protectedDataStoreService.readFromResources(postFix, () -> {
map.putAll(protectedDataStoreService.getMap());
protectedDataStoreServiceReady.set(true);
});
resourceDataStoreService.readFromResources(postFix, () -> resourceDataStoreServiceReady.set(true));
readFromResourcesCompleteBinding = EasyBind.combine(appendOnlyDataStoreServiceReady,
protectedDataStoreServiceReady,
resourceDataStoreServiceReady,
@ -225,6 +218,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
completeHandler.run();
}
});
appendOnlyDataStoreService.readFromResources(postFix, () -> appendOnlyDataStoreServiceReady.set(true));
protectedDataStoreService.readFromResources(postFix, () -> {
map.putAll(protectedDataStoreService.getMap());
protectedDataStoreServiceReady.set(true);
});
resourceDataStoreService.readFromResources(postFix, () -> resourceDataStoreServiceReady.set(true));
}
// Uses synchronous execution on the userThread. Only used by tests. The async methods should be used by app code.

View File

@ -55,6 +55,10 @@ public class AppendOnlyDataStoreService {
}
public void readFromResources(String postFix, Runnable completeHandler) {
if (services.isEmpty()) {
completeHandler.run();
return;
}
AtomicInteger remaining = new AtomicInteger(services.size());
services.forEach(service -> {
service.readFromResources(postFix, () -> {

View File

@ -56,6 +56,10 @@ public class ProtectedDataStoreService {
}
public void readFromResources(String postFix, Runnable completeHandler) {
if (services.isEmpty()) {
completeHandler.run();
return;
}
AtomicInteger remaining = new AtomicInteger(services.size());
services.forEach(service -> {
service.readFromResources(postFix, () -> {

View File

@ -46,6 +46,10 @@ public class ResourceDataStoreService {
}
public void readFromResources(String postFix, Runnable completeHandler) {
if (services.isEmpty()) {
completeHandler.run();
return;
}
AtomicInteger remaining = new AtomicInteger(services.size());
services.forEach(service -> {
service.readFromResources(postFix, () -> {