Skip to content

Commit

Permalink
Fix JarAnalyzer warnings on Payara (open-telemetry#10458)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored and steverao committed Feb 16, 2024
1 parent 6ab27e9 commit 2b350b8
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.JmxRuntimeMetricsUtil;
import io.opentelemetry.sdk.common.Clock;
import io.opentelemetry.sdk.internal.DaemonThreadFactory;
import java.io.File;
import java.io.IOException;
import java.lang.instrument.ClassFileTransformer;
import java.net.URI;
Expand Down Expand Up @@ -131,6 +132,22 @@ private void handle(ProtectionDomain protectionDomain) {
return;
}

// Payara 5 and 6 have url with file protocol that fail on openStream with
// java.io.IOException: no entry name specified
// at
// java.base/sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:160)
// To avoid this here we recreate the URL when it points to a file.
if ("file".equals(archiveUrl.getProtocol())) {
try {
File archiveFile = new File(archiveUrl.toURI().getSchemeSpecificPart());
if (archiveFile.exists() && archiveFile.isFile()) {
archiveUrl = archiveFile.toURI().toURL();
}
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to normalize location URL: " + archiveUrl, e);
}
}

// Only code locations with .jar and .war extension should make it here
toProcess.add(archiveUrl);
}
Expand Down

0 comments on commit 2b350b8

Please sign in to comment.