refactor(接口测试): 按照线程组隔离文件读取逻辑

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2023-08-07 15:38:12 +08:00 committed by fit2-zhao
parent f96c359571
commit 4f9f9ee2d1
1 changed files with 10 additions and 3 deletions

View File

@ -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 {