Make sure that same classloaders get same weak ref
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/DDCachingPoolStrategy.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/DDCachingPoolStrategy.java
@@ -82,12 +82,15 @@ public class DDCachingPoolStrategy implements PoolStrategy {
return createCachingTypePool(bootstrapCacheProvider, classFileLocator);
}
- WeakReference<ClassLoader> loaderRef = loaderRefCache.getIfPresent(classLoader);
+ WeakReference<ClassLoader> loaderRef;
+ synchronized (loaderRefCache) {
+ loaderRef = loaderRefCache.getIfPresent(classLoader);
if (loaderRef == null) {
loaderRef = new WeakReference<>(classLoader);
loaderRefCache.put(classLoader, loaderRef);
}
+ }
final int loaderHash = classLoader.hashCode();
return createCachingTypePool(loaderHash, loaderRef, classFileLocator);

Make sure that same classloaders get same weak ref