Skip to content

Commit

Permalink
Send correct URI in DELETE /runtimedetails/{ker_id} call (#484)
Browse files Browse the repository at this point in the history
* Send correct URI in DELETE /runtimedetails/{ker_id} call

* Make method package-private

* Use runtimeId not exposedUrl
  • Loading branch information
Sophietje authored Feb 28, 2024
1 parent cb21960 commit cc15b66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> response = this.httpClient.send(request, BodyHandlers.ofString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit cc15b66

Please sign in to comment.