Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JarAnalyzer warnings on Payara #10458

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading