Skip to content

Commit aec88b8

Browse files
authored
Fix version discovery for URL-encoded jars (#665)
1 parent 9e8b64f commit aec88b8

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

apm-agent-core/src/main/java/co/elastic/apm/agent/bci/bytebuddy/CustomElementMatchers.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.slf4j.LoggerFactory;
3434

3535
import javax.annotation.Nullable;
36+
import java.io.File;
3637
import java.io.IOException;
3738
import java.net.JarURLConnection;
3839
import java.net.URL;
@@ -156,13 +157,7 @@ public boolean matches(@Nullable ProtectionDomain protectionDomain) {
156157
if (urlConnection instanceof JarURLConnection) {
157158
jarFile = ((JarURLConnection) urlConnection).getJarFile();
158159
} else {
159-
try {
160-
jarFile = new JarFile(jarUrl.getFile());
161-
} catch (IOException e) {
162-
// Maybe the URL is encoded- try to decode
163-
//noinspection CharsetObjectCanBeUsed - can't use this API as it is from Java 10 only
164-
jarFile = new JarFile(URLDecoder.decode(jarUrl.getFile(), "UTF-8"));
165-
}
160+
jarFile = new JarFile(new File(jarUrl.toURI()));
166161
}
167162
Manifest manifest = jarFile.getManifest();
168163
if (manifest != null) {

0 commit comments

Comments
 (0)