Call completeHandler if services in store services is empty.

If oen starts with --daoActivated=false there is no service
set up in one of the data store services so it never calls
the result handler and the app never starts up.
This commit is contained in:
chimp1984 2020-12-16 16:21:10 -05:00 committed by Christoph Atteneder
parent c5c93b213d
commit f270b9c6fa
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
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, () -> {