From ff4b23a23b45decf7c4344740be1fcac7190b400 Mon Sep 17 00:00:00 2001 From: crazyhzm Date: Thu, 28 Mar 2024 14:27:22 +0800 Subject: [PATCH] Remove url ref in native scenario Signed-off-by: crazyhzm --- .../utils/ClassLoaderResourceLoader.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassLoaderResourceLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassLoaderResourceLoader.java index 8c743c214f1..c62966fc444 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassLoaderResourceLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassLoaderResourceLoader.java @@ -16,14 +16,12 @@ */ package org.apache.dubbo.common.utils; -import org.apache.dubbo.common.aot.NativeDetector; import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.resource.GlobalResourcesRepository; import java.io.IOException; import java.lang.ref.SoftReference; -import java.lang.reflect.Field; import java.net.URL; import java.util.Collection; import java.util.Collections; @@ -32,7 +30,6 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; @@ -81,15 +78,9 @@ public static Set loadResources(String fileName, ClassLoader currentClassLo Enumeration urls; try { urls = currentClassLoader.getResources(fileName); - boolean isNative = NativeDetector.inNativeImage(); if (urls != null) { while (urls.hasMoreElements()) { URL url = urls.nextElement(); - if (isNative) { - // In native mode, the address of each URL is the same instead of different paths, so it is - // necessary to set the ref to make it different - setRef(url); - } set.add(url); } } @@ -113,15 +104,6 @@ public static void destroy() { } } - private static void setRef(URL url) { - try { - Field field = URL.class.getDeclaredField("ref"); - field.setAccessible(true); - field.set(url, UUID.randomUUID().toString()); - } catch (Throwable ignore) { - } - } - // for test protected static SoftReference>>> getClassLoaderResourcesCache() { return classLoaderResourcesCache;