From 4f9f9ee2d1de4f267d20d5d0e0e358dfe88c7327 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 7 Aug 2023 15:38:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=8C=89=E7=85=A7=E7=BA=BF=E7=A8=8B=E7=BB=84=E9=9A=94?= =?UTF-8?q?=E7=A6=BB=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fit2-zhao --- .../java/org/apache/jmeter/services/FileServer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/services/FileServer.java b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/services/FileServer.java index fb15a888f3..20f964dad5 100644 --- a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/services/FileServer.java +++ b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/services/FileServer.java @@ -255,8 +255,8 @@ public class FileServer { throw new IllegalArgumentException("Alias must not be null"); } // todo 这里更改了原始代码 - if(!new File(filename).exists()){ - log.error("file does not exist [ "+ filename+" ]"); + if (!new File(filename).exists()) { + log.error("file does not exist [ " + filename + " ]"); return ""; } @@ -575,8 +575,15 @@ public class FileServer { * @return {@link File} instance */ public File getResolvedFile(String path) { + log.info("getResolvedFile: {}", path); + String threadName = JMeterContextService.getContext().getThread().getThreadName(); + if (!StringUtils.contains(path, threadName)) { + path = StringUtils.join(threadName, path); + } reserveFile(path); - return files.get(path).file; + + FileEntry fileEntry = files.get(path); + return fileEntry != null ? fileEntry.file : null; } private static class FileEntry {