@Override
public synchronized final CompletableFuture<List<WebService<?>>> startDiscoverer()
{
+ Cache.log.debug("Requesting service discovery");
while (true)
{
if (state.get() == AGAIN)
}
if (state.compareAndSet(END, BEGIN) || state.compareAndSet(BEGIN, AGAIN))
{
+ Cache.log.debug("State changed to " + state.get());
final var oldTask = discoveryTask;
CompletableFuture<List<WebService<?>>> task = oldTask
.handleAsync((_r, _e) -> {
}
return services = allServices;
});
- task.thenAccept(services -> {
+ task.<Void>handle((services, exception) -> {
while (true)
{
if (state.get() == END)
// should never happen, throw exception to break the loop just in case
throw new AssertionError();
if (state.compareAndSet(BEGIN, END) || state.compareAndSet(AGAIN, BEGIN))
+ Cache.log.debug("Discovery ended, state is " + state.get());
break;
}
- fireServicesChanged(services);
+ if (services != null)
+ fireServicesChanged(services);
+ return null;
});
+ Cache.log.debug("Spawned task " + task);
+ Cache.log.debug("Killing task " + oldTask);
oldTask.cancel(false);
return discoveryTask = task;
}