Read correct manifest (#3439)

* Read correct manifest

* Unused field removed
This commit is contained in:
Nikita Salnikov-Tarnovski 2021-07-01 18:25:01 +03:00 committed by GitHub
parent e2aae6fc87
commit 47819633e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 14 deletions

View File

@ -43,7 +43,6 @@ public class AgentClassLoader extends URLClassLoader {
System.getProperty("otel.javaagent.experimental.initializer.jar", "");
private static final String META_INF = "META-INF/";
private static final String META_INF_MANIFEST_MF = META_INF + "MANIFEST.MF";
private static final String META_INF_VERSIONS = META_INF + "versions/";
// multi release jars were added in java 9
@ -94,7 +93,7 @@ public class AgentClassLoader extends URLClassLoader {
jarBase =
new URL("x-internal-jar", null, 0, "/", new AgentClassLoaderUrlStreamHandler(jarFile));
codeSource = new CodeSource(javaagentFile.toURI().toURL(), (Certificate[]) null);
manifest = getManifest(jarFile, jarEntryPrefix + META_INF_MANIFEST_MF);
manifest = jarFile.getManifest();
} catch (IOException e) {
throw new IllegalStateException("Unable to open agent jar", e);
}
@ -123,18 +122,6 @@ public class AgentClassLoader extends URLClassLoader {
return Integer.parseInt(javaSpecVersion);
}
private static Manifest getManifest(JarFile jarFile, String manifestPath) {
JarEntry manifestEntry = jarFile.getJarEntry(manifestPath);
if (manifestEntry == null) {
throw new IllegalStateException("Manifest entry not found");
}
try (InputStream is = jarFile.getInputStream(manifestEntry)) {
return new Manifest(is);
} catch (IOException exception) {
throw new IllegalStateException("Failed to read manifest", exception);
}
}
@Override
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
// ContextStorageOverride is meant for library instrumentation we don't want it to apply to our