]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21059 Fix incorrect character encoding in email subject
authorAlain Kermis <alain.kermis@sonarsource.com>
Wed, 31 Jan 2024 13:49:45 +0000 (14:49 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 1 Feb 2024 20:02:47 +0000 (20:02 +0000)
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssuesEmailTemplate.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssueChangesEmailTemplate.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssuesEmailTemplateTest.java

index 57fef428c9ef3964c727baffdcd699016cf0f1ea..250f17973c4f425b99cb27a2ab7dba8c326ba1e1 100644 (file)
@@ -75,9 +75,7 @@ public class ChangesOnMyIssuesEmailTemplate extends IssueChangesEmailTemplate {
   }
 
   private static String buildAnalysisSubject(Project project) {
-    StringBuilder res = new StringBuilder("Analysis has changed some of your issues in ");
-    toString(res, project);
-    return res.toString();
+    return "Analysis has changed some of your issues in " + toSubject(project);
   }
 
   private String buildAnalysisMessage(Project project, ChangesOnMyIssuesNotification notification) {
index f28fa1bc835f7561ad8913fd36b61118e6557868..8ba368894abfd5576ef45b9bed4e2a6ca8ae47a9 100644 (file)
@@ -81,6 +81,13 @@ public abstract class IssueChangesEmailTemplate implements EmailTemplate {
     this.settings = settings;
   }
 
+  /**
+   * Used to build the subject for the email
+   */
+  protected static String toSubject(Project project) {
+    return project.getProjectName() + project.getBranchName().map(branchName -> " (" + branchName + ")").orElse("");
+  }
+
   /**
    * Adds "projectName" or "projectName, branchName" if branchName is non null
    */
index 54a88f6cccc4ca15274ca355cdb891ea06d7a081..4205cfd7ed9fa2ae0a880ac72f88858e2e0afab7 100644 (file)
@@ -137,7 +137,7 @@ public class ChangesOnMyIssuesEmailTemplateTest {
     EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));
 
     Project project = changedIssues.iterator().next().getProject();
-    assertThat(emailMessage.getSubject()).isEqualTo("Analysis has changed some of your issues in " + project.getProjectName() + ", " + project.getBranchName().get());
+    assertThat(emailMessage.getSubject()).isEqualTo("Analysis has changed some of your issues in " + project.getProjectName() + " (" + project.getBranchName().get() + ")");
   }
 
   @Test