优化飞书获取推送模板重复读取文件

pull/97/head
weihu 3 years ago
parent c674b263f5
commit 23f3cff8bf

@ -24,6 +24,7 @@ import org.springframework.util.ResourceUtils;
import java.io.FileNotFoundException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -45,6 +46,8 @@ public class LarkSendMessageHandler implements SendMessageHandler {
private final InstanceInfo instanceInfo;
private static volatile String larkJson;
@Override
public String getType() {
return NotifyPlatformEnum.LARK.name();
@ -166,7 +169,14 @@ public class LarkSendMessageHandler implements SendMessageHandler {
}
private String getLarkJson(String filePath) throws FileNotFoundException {
return FileUtil.readString(ResourceUtils.getFile(filePath), StandardCharsets.UTF_8);
if (Objects.isNull(larkJson)) {
synchronized (LarkSendMessageHandler.class) {
if (Objects.isNull(larkJson)) {
larkJson = FileUtil.readString(ResourceUtils.getFile(filePath), StandardCharsets.UTF_8);
}
}
}
return larkJson;
}
private String getReceives(NotifyDTO notifyConfig) {
@ -189,4 +199,5 @@ public class LarkSendMessageHandler implements SendMessageHandler {
}
}
}

Loading…
Cancel
Save