Make sure that same classloaders get same weak ref
@@ -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);
