From cc15b66ac8063598721fff9ed47ccef510cd01a7 Mon Sep 17 00:00:00 2001 From: Sophie Lathouwers Date: Wed, 28 Feb 2024 16:49:30 +0100 Subject: [PATCH] Send correct URI in DELETE /runtimedetails/{ker_id} call (#484) * Send correct URI in DELETE /runtimedetails/{ker_id} call * Make method package-private * Use runtimeId not exposedUrl --- .../runtime/messaging/RemoteKerConnection.java | 10 ++++------ .../runtime/messaging/RemoteKerConnectionManager.java | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java index 0bec8c12..eb2c0b39 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnection.java @@ -3,15 +3,13 @@ import static eu.knowledge.engine.smartconnector.runtime.messaging.Utils.stripUserInfoFromURI; import java.io.IOException; -import java.net.Authenticator; -import java.net.PasswordAuthentication; -import java.net.URI; -import java.net.URISyntaxException; +import java.net.*; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.LocalDateTime; import java.util.ArrayList; @@ -232,9 +230,9 @@ public void start() { public void stop() { if (this.isAvailable()) { try { + String ker_id = URLEncoder.encode(dispatcher.getMyKnowledgeEngineRuntimeDetails().getRuntimeId(), StandardCharsets.UTF_8); HttpRequest request = HttpRequest - .newBuilder(new URI(this.remoteKerUri + "/runtimedetails/" - + dispatcher.getKnowledgeDirectoryConnectionManager().getMyKnowledgeDirectoryId())) + .newBuilder(new URI(this.remoteKerUri + "/runtimedetails/" + ker_id)) .header("Content-Type", "application/json").DELETE().build(); HttpResponse response = this.httpClient.send(request, BodyHandlers.ofString()); diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java index 94b61f04..62500c79 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java @@ -139,9 +139,8 @@ private synchronized void queryKnowledgeDirectory() { } if (!kerIds.contains(e.getKey())) { - // According the the Knowledge Directory, this KER doesn't exist (anymore) + // According to the Knowledge Directory, this KER doesn't exist (anymore) LOG.info("Removing peer that is now gone: {}", e.getValue().getRemoteKerUri()); - e.getValue().stop(); it.remove(); this.unavailableRemoteKerConnections.remove(e.getKey()); }