From 8299316af8ad74a9b5369c954e7f371340bf52a4 Mon Sep 17 00:00:00 2001 From: LamGC Date: Tue, 10 Dec 2024 23:35:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(extension):=20=E4=BD=BF=E7=94=A8=20URI?= =?UTF-8?q?=20=E8=80=8C=E4=B8=8D=E6=98=AF=20URL=20=E6=9D=A5=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E9=87=8D=E5=A4=8D=E9=A1=B9,=20=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=BD=9C=E5=9C=A8=E7=9A=84=20URL=20hashCode=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scalabot-app/src/main/kotlin/ExtensionFinders.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scalabot-app/src/main/kotlin/ExtensionFinders.kt b/scalabot-app/src/main/kotlin/ExtensionFinders.kt index 5a4a2ee..27e8c52 100644 --- a/scalabot-app/src/main/kotlin/ExtensionFinders.kt +++ b/scalabot-app/src/main/kotlin/ExtensionFinders.kt @@ -26,6 +26,7 @@ import org.jdom2.input.SAXBuilder import org.jdom2.xpath.XPathFactory import java.io.File import java.io.InputStream +import java.net.URI import java.net.URL import java.net.URLClassLoader import java.util.* @@ -396,7 +397,6 @@ internal class MavenRepositoryExtensionFinder( /** * Maven 中央仓库 Url. */ - @Suppress("MemberVisibilityCanBePrivate") const val MAVEN_CENTRAL_URL = "https://repo1.maven.org/maven2/" /** @@ -466,17 +466,19 @@ internal class MavenRepositoryExtensionFinder( throw IllegalArgumentException("Unsupported FoundExtensionPackage type: $foundExtensionPackage") } - val urls = mutableSetOf() + val urls = mutableSetOf() for (dependency in foundExtensionPackage.dependencies) { val dependencyFile = dependency.file ?: continue - urls.add(dependencyFile.toURI().toURL()) + urls.add(dependencyFile.toURI()) } // 将依赖的 ClassLoader 与 ExtensionPackage 的 ClassLoader 分开 // 这么做可以防范依赖中隐藏的 SPI 注册, 避免安全隐患. val dependenciesUrlArray = urls.toTypedArray() - val dependenciesClassLoader = URLClassLoader(dependenciesUrlArray) + val dependenciesClassLoader = URLClassLoader( + dependenciesUrlArray.map { it.toURL() }.toTypedArray() + ) return ExtensionClassLoader( arrayOf(foundExtensionPackage.getPackageFile().toURI().toURL()),