From 9b3fb2d9e6447556300755e3443d3d6c86f477ca Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 17 Feb 2023 19:15:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DMock=E5=90=8E=E7=BD=AE=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD=E5=88=B0minio=E4=B8=8A?= =?UTF-8?q?=E9=9D=A2jar=E5=8C=85=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Mock后置脚本无法加载到minio上面jar包的问题 --- .../commons/utils/mock/MockScriptEngineUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockScriptEngineUtils.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockScriptEngineUtils.java index f848719e12..12581c9aef 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockScriptEngineUtils.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockScriptEngineUtils.java @@ -8,8 +8,7 @@ import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.JSONUtil; import io.metersphere.commons.utils.LogUtil; -import io.metersphere.jmeter.MsClassLoader; -import io.metersphere.jmeter.MsDynamicClassLoader; +import io.metersphere.jmeter.ProjectClassLoader; import io.metersphere.metadata.service.FileMetadataService; import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; @@ -78,7 +77,9 @@ public class MockScriptEngineUtils { } if (engine != null) { - MsDynamicClassLoader loader = MsClassLoader.loadJar(getJarPaths(projectId)); + ClassLoader loader = ProjectClassLoader.getClassLoader(new ArrayList<>() {{ + this.add(projectId); + }}); Thread.currentThread().setContextClassLoader(loader); engine.eval(preScript); }