Skip to content

Commit

Permalink
resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Feb 21, 2024
1 parent 9d814da commit 69c274f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ public IntermediateResponse<ServiceRef> handle(RequestParameters params) throws
}
// check incase custom target has short form connection url (i.e `localhost:0`,
// etc)
if (connectUrl.matches("localhost:\\d+")) {
connectUrl = connectUrl.strip();
boolean isShortForm = connectUrl.matches("^[^\\s/:]+:\\d+$");
if (isShortForm) {
String[] connectUrlParts = connectUrl.split(":");
String host = connectUrlParts[0];
int port = Integer.parseInt(connectUrlParts[1]);
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/itest/CustomTargetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package itest;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand All @@ -37,6 +37,7 @@
import itest.util.ITestCleanupFailedException;
import itest.util.http.JvmIdWebRequest;
import itest.util.http.StoredCredential;
import org.apache.http.client.utils.URLEncodedUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -350,7 +351,9 @@ void shouldBeAbleToDeleteTarget()
});

String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi";
String encodedUrl = URLEncoder.encode(jmxServiceUrl, StandardCharsets.UTF_8);
String encodedUrl =
URLEncodedUtils.formatSegments(
Collections.singletonList(jmxServiceUrl), StandardCharsets.UTF_8);
CompletableFuture<JsonObject> response = new CompletableFuture<>();
webClient
.delete("/api/v2/targets/" + encodedUrl)
Expand All @@ -377,7 +380,6 @@ void targetShouldNoLongerAppearInListing() throws ExecutionException, Interrupte
});
JsonArray body = response.get();
MatcherAssert.assertThat(body, Matchers.notNullValue());

MatcherAssert.assertThat(body.size(), Matchers.equalTo(1));

JsonObject selfJdp =
Expand Down

0 comments on commit 69c274f

Please sign in to comment.