Prevent AgentClassLoader from loading ContextStorageOverride
MODIFY
javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java
javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java
@@ -81,6 +81,17 @@ public class AgentClassLoader extends URLClassLoader {
}
}
+ @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
+ // bundled grpc
+ if ("io.grpc.override.ContextStorageOverride".equals(name)) {
+ throw new ClassNotFoundException(name);
+ }
+
+ return super.loadClass(name, resolve);
+ }
+
@Override
public URL getResource(String resourceName) {
URL bootstrapResource = bootstrapProxy.getResource(resourceName);

Prevent AgentClassLoader from loading ContextStorageOverride (#2847)