From 23f3cff8bfa16220f45db9dc0b9c9d524b8cd157 Mon Sep 17 00:00:00 2001 From: weihu Date: Wed, 16 Feb 2022 16:52:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A3=9E=E4=B9=A6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8E=A8=E9=80=81=E6=A8=A1=E6=9D=BF=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/alarm/lark/LarkSendMessageHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/lark/LarkSendMessageHandler.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/lark/LarkSendMessageHandler.java index bebdb62d..20cae30d 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/lark/LarkSendMessageHandler.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/lark/LarkSendMessageHandler.java @@ -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 { } } + }