You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/09/21 08:37:07 UTC

[incubator-eventmesh] branch master updated: [ISSUE #1358] Update FileWebHookConfigOperation for webhook config

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e7cdd16 [ISSUE #1358] Update FileWebHookConfigOperation for webhook config
     new 410c2e51 Merge pull request #1359 from githublaohu/webhook-repair5
5e7cdd16 is described below

commit 5e7cdd16c4df1676063ad0ef62000eaf14efd03c
Author: githublaohu <Ni...@989898>
AuthorDate: Wed Sep 21 14:55:02 2022 +0800

    [ISSUE #1358] Update FileWebHookConfigOperation for webhook config
---
 .../webhook/admin/FileWebHookConfigOperation.java        | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/eventmesh-webhook/eventmesh-webhook-admin/src/main/java/org/apache/eventmesh/webhook/admin/FileWebHookConfigOperation.java b/eventmesh-webhook/eventmesh-webhook-admin/src/main/java/org/apache/eventmesh/webhook/admin/FileWebHookConfigOperation.java
index 6b517df3..d4be4a24 100644
--- a/eventmesh-webhook/eventmesh-webhook-admin/src/main/java/org/apache/eventmesh/webhook/admin/FileWebHookConfigOperation.java
+++ b/eventmesh-webhook/eventmesh-webhook-admin/src/main/java/org/apache/eventmesh/webhook/admin/FileWebHookConfigOperation.java
@@ -21,6 +21,7 @@ import org.apache.eventmesh.common.utils.JsonUtils;
 import org.apache.eventmesh.webhook.api.WebHookConfig;
 import org.apache.eventmesh.webhook.api.WebHookConfigOperation;
 import org.apache.eventmesh.webhook.api.WebHookOperationConstant;
+import org.apache.eventmesh.webhook.api.utils.StringUtils;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
@@ -31,8 +32,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -165,16 +164,9 @@ public class FileWebHookConfigOperation implements WebHookConfigOperation {
     }
 
     private File getWebhookConfigFile(WebHookConfig webHookConfig) {
-        String webhookConfigFilePath = null;
-        try {
-            // use URLEncoder.encode before, because the path may contain some speacial char like '/', which is illegal as a file name.
-            webhookConfigFilePath = this.getWebhookConfigManuDir(webHookConfig)
-                + WebHookOperationConstant.FILE_SEPARATOR + URLEncoder.encode(webHookConfig.getCallbackPath(), "UTF-8")
-                + WebHookOperationConstant.FILE_EXTENSION;
-        } catch (UnsupportedEncodingException e) {
-            logger.error("get webhookConfig file path {} failed", webHookConfig.getCallbackPath(), e);
-        }
-        assert webhookConfigFilePath != null;
+        String webhookConfigFilePath = this.getWebhookConfigManuDir(webHookConfig) + WebHookOperationConstant.FILE_SEPARATOR
+            + StringUtils.getFileName(webHookConfig.getCallbackPath());
+
         return new File(webhookConfigFilePath);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org