From cdf9dd86bfb3b5d2084e5c5158c99907a8ae326b Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 15 Aug 2024 14:09:45 +0200 Subject: [PATCH 1/3] Dummy commit to have a diff --- .../sdk/bytebuddy/CustomElementMatchersTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java index 6f24e36a8c..6a90e78c1f 100644 --- a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java +++ b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java @@ -26,13 +26,13 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; -import java.net.URI; -import java.nio.file.Files; import java.nio.file.FileSystem; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.CodeSigner; @@ -42,7 +42,12 @@ import java.util.List; import java.util.Map; -import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.*; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.implementationVersionGte; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.implementationVersionLte; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.isAgentClassLoader; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.isInAnyPackage; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.isInternalPluginClassLoader; import static net.bytebuddy.matcher.ElementMatchers.none; import static org.assertj.core.api.Assertions.assertThat; @@ -76,6 +81,7 @@ void testSemVerLteWithEncodedFileUrl() throws MalformedURLException, URISyntaxEx void testSemVerFallbackOnMavenProperties(@TempDir Path tempDir) throws URISyntaxException, IOException { // Relying on Apache httpclient-4.5.6.jar // creates a copy of the jar without the manifest so we should parse maven properties + URL originalUrl = HttpClient.class.getProtectionDomain().getCodeSource().getLocation(); Path modifiedJar = tempDir.resolve("test.jar"); try { From 405482e66b9b534da734aaa4ff1442721502b77c Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 15 Aug 2024 14:21:23 +0200 Subject: [PATCH 2/3] Fix URI creation for windows --- .../apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java index 6a90e78c1f..40228ece61 100644 --- a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java +++ b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java @@ -81,7 +81,6 @@ void testSemVerLteWithEncodedFileUrl() throws MalformedURLException, URISyntaxEx void testSemVerFallbackOnMavenProperties(@TempDir Path tempDir) throws URISyntaxException, IOException { // Relying on Apache httpclient-4.5.6.jar // creates a copy of the jar without the manifest so we should parse maven properties - URL originalUrl = HttpClient.class.getProtectionDomain().getCodeSource().getLocation(); Path modifiedJar = tempDir.resolve("test.jar"); try { @@ -90,7 +89,7 @@ void testSemVerFallbackOnMavenProperties(@TempDir Path tempDir) throws URISyntax Map fsProperties = new HashMap<>(); fsProperties.put("create", "false"); - URI fsUri = URI.create("jar:file://" + modifiedJar.toAbsolutePath()); + URI fsUri = URI.create("jar:" + modifiedJar.toUri().toString()); try (FileSystem zipFs = FileSystems.newFileSystem(fsUri, fsProperties)) { Files.delete(zipFs.getPath("META-INF", "MANIFEST.MF")); } From 9255d831b080e27058f8a2c208f297192073487f Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 15 Aug 2024 14:57:26 +0200 Subject: [PATCH 3/3] Remove unnecessary toString --- .../apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java index 40228ece61..20398a47bd 100644 --- a/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java +++ b/apm-agent-plugin-sdk/src/test/java/co/elastic/apm/agent/sdk/bytebuddy/CustomElementMatchersTest.java @@ -89,7 +89,7 @@ void testSemVerFallbackOnMavenProperties(@TempDir Path tempDir) throws URISyntax Map fsProperties = new HashMap<>(); fsProperties.put("create", "false"); - URI fsUri = URI.create("jar:" + modifiedJar.toUri().toString()); + URI fsUri = URI.create("jar:" + modifiedJar.toUri()); try (FileSystem zipFs = FileSystems.newFileSystem(fsUri, fsProperties)) { Files.delete(zipFs.getPath("META-INF", "MANIFEST.MF")); }