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

caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 51d47de6de [Bug] [ALERT-9487] change email attachment filename to add 
random string to avoid issues (#9498)
51d47de6de is described below

commit 51d47de6deec9990c03d5a373064cb3a61355abf
Author: Tq <[email protected]>
AuthorDate: Fri Apr 15 10:13:13 2022 +0800

    [Bug] [ALERT-9487] change email attachment filename to add random string to 
avoid issues (#9498)
    
    * change email attachment filename to add random string to avoid always use 
same file
    
    * change email attachment filename to add random string to avoid always use 
same file
---
 .../org/apache/dolphinscheduler/plugin/alert/email/MailSender.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
 
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
index e64b4a7158..a7305cf741 100644
--- 
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
+++ 
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
@@ -38,6 +38,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.UUID;
 
 import javax.activation.CommandMap;
 import javax.activation.MailcapCommandMap;
@@ -326,13 +327,15 @@ public final class MailSender {
         part1.setContent(partContent, EmailConstants.TEXT_HTML_CHARSET_UTF_8);
         // set attach file
         MimeBodyPart part2 = new MimeBodyPart();
-        File file = new File(xlsFilePath + EmailConstants.SINGLE_SLASH + title 
+ EmailConstants.EXCEL_SUFFIX_XLSX);
+        // add random uuid to filename to avoid potential issue
+        String randomFilename = title + UUID.randomUUID();
+        File file = new File(xlsFilePath + EmailConstants.SINGLE_SLASH + 
randomFilename + EmailConstants.EXCEL_SUFFIX_XLSX);
         if (!file.getParentFile().exists()) {
             file.getParentFile().mkdirs();
         }
         // make excel file
 
-        ExcelUtils.genExcelFile(content, title, xlsFilePath);
+        ExcelUtils.genExcelFile(content, randomFilename, xlsFilePath);
 
         part2.attachFile(file);
         part2.setFileName(MimeUtility.encodeText(title + 
EmailConstants.EXCEL_SUFFIX_XLSX, EmailConstants.UTF_8, "B"));

Reply via email to