Skip to content

Commit 2b350b8

Browse files
lauritsteverao
authored andcommitted
Fix JarAnalyzer warnings on Payara (open-telemetry#10458)
1 parent 6ab27e9 commit 2b350b8

File tree

1 file changed

+17
-0
lines changed
  • instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/src/main/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8

1 file changed

+17
-0
lines changed

instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/src/main/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzer.java

+17
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.JmxRuntimeMetricsUtil;
1919
import io.opentelemetry.sdk.common.Clock;
2020
import io.opentelemetry.sdk.internal.DaemonThreadFactory;
21+
import java.io.File;
2122
import java.io.IOException;
2223
import java.lang.instrument.ClassFileTransformer;
2324
import java.net.URI;
@@ -131,6 +132,22 @@ private void handle(ProtectionDomain protectionDomain) {
131132
return;
132133
}
133134

135+
// Payara 5 and 6 have url with file protocol that fail on openStream with
136+
// java.io.IOException: no entry name specified
137+
// at
138+
// java.base/sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:160)
139+
// To avoid this here we recreate the URL when it points to a file.
140+
if ("file".equals(archiveUrl.getProtocol())) {
141+
try {
142+
File archiveFile = new File(archiveUrl.toURI().getSchemeSpecificPart());
143+
if (archiveFile.exists() && archiveFile.isFile()) {
144+
archiveUrl = archiveFile.toURI().toURL();
145+
}
146+
} catch (Exception e) {
147+
logger.log(Level.WARNING, "Unable to normalize location URL: " + archiveUrl, e);
148+
}
149+
}
150+
134151
// Only code locations with .jar and .war extension should make it here
135152
toProcess.add(archiveUrl);
136153
}

0 commit comments

Comments
 (0)