pandaapo commented on code in PR #4344:
URL: https://github.com/apache/eventmesh/pull/4344#discussion_r1296505244
##########
eventmesh-webhook/eventmesh-webhook-admin/src/main/java/org/apache/eventmesh/webhook/admin/FileWebHookConfigOperation.java:
##########
@@ -173,18 +175,25 @@ private WebHookConfig getWebHookConfigFromFile(final File
webhookConfigFile) {
}
public static boolean writeToFile(final File webhookConfigFile, final
WebHookConfig webHookConfig) {
- try (FileOutputStream fos = new FileOutputStream(webhookConfigFile);
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos,
StandardCharsets.UTF_8))) {
- // lock this file, and will auto release after fos close
- fos.getChannel().lock();
-
bw.write(Objects.requireNonNull(JsonUtils.toJSONString(webHookConfig)));
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("write webhookConfig {} to file error",
webHookConfig.getCallbackPath());
+ // Wait for the previous cacheInit to complete and ensure the
atomicity of countDown in case of concurrency
+ synchronized (SharedLatchHolder.lock) {
+ // Reset latch count
+ SharedLatchHolder.latch = new CountDownLatch(1);
Review Comment:
https://github.com/apache/eventmesh/blob/5005cada8c66193acbff2a278ca3f8bca117de37/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/storage/WebhookFileListener.java#L173-L176
Now `SharedLatchHolder.latch` seems redundant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]