Skip to content

Commit

Permalink
Typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylern committed Feb 15, 2024
1 parent 81e1851 commit 7dd59c6
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/main/java/qupath/ext/omero/core/WebClients.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ public static CompletableFuture<WebClient> createClient(String url, boolean canS
logger.warn(String.format("Client for %s already being created", serverURI.get()));
return CompletableFuture.completedFuture(WebClient.createInvalidClient(WebClient.FailReason.ALREADY_CREATING));
} else {
return createClientAsync(serverURI.get(), canSkipAuthentication, args);
clientsBeingCreated.add(serverURI.get());

return WebClient.create(serverURI.get(), canSkipAuthentication, args).thenApply(client -> {
if (client.getStatus().equals(WebClient.Status.SUCCESS)) {
ClientsPreferencesManager.addURI(client.getApisHandler().getWebServerURI());
updateClients(client, Operation.ADD);
}
clientsBeingCreated.remove(serverURI.get());

return client;
});
}
});
} else {
Expand Down Expand Up @@ -150,20 +160,6 @@ private static Optional<WebClient> getExistingClient(URI uri) {
return clients.stream().filter(e -> e.getApisHandler().getWebServerURI().equals(uri)).findAny();
}

private static CompletableFuture<WebClient> createClientAsync(URI uri, boolean canSkipAuthentication, String... args) {
clientsBeingCreated.add(uri);

return WebClient.create(uri, canSkipAuthentication, args).thenApply(client -> {
if (client.getStatus().equals(WebClient.Status.SUCCESS)) {
ClientsPreferencesManager.addURI(client.getApisHandler().getWebServerURI());
updateClients(client, Operation.ADD);
}
clientsBeingCreated.remove(uri);

return client;
});
}

private static synchronized void updateClients(WebClient client, Operation operation) {
if (operation.equals(Operation.ADD)) {
clients.add(client);
Expand Down

0 comments on commit 7dd59c6

Please sign in to comment.