Skip to content

Commit

Permalink
Force English locale in mail decimal formatting
Browse files Browse the repository at this point in the history
Locale should be forced to English (rather that system default) since the whole mail is written in English.
Without it, we could end up with mixed languages/formatting such as "GC Duration greater than 1000,0 ms" with wrong decimal separator.

Note that the issue was seen from JUnit EmailTemplateTest:

Expected :Tiny template: Alert [open] message: GC Duration greater than 1000,0 ms for App Server thevault~Local
Actual   :Tiny template: Alert [open] message: GC Duration greater than 1000.0 ms for App Server thevault~Local
  • Loading branch information
jotak committed Aug 16, 2016
1 parent 5641f92 commit 64cf80e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public Map<String, String> processTemplate(ActionMessage msg) throws Exception {

/*
Invoke freemarker template with PluginMessageDescription as root object for dynamic data.
PluginMessageDescription fields are accesible within .ftl templates.
PluginMessageDescription fields are accessible within .ftl templates.
*/
StringWriter writerPlain = new StringWriter();
StringWriter writerHtml = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package org.hawkular.alerts.actions.email;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -116,7 +118,7 @@ public class PluginMessageDescription {
/** Base URL to be used on templates to build links into main UI */
private String baseUrl;

private DecimalFormat decimalFormat = new DecimalFormat("####0.0");
private DecimalFormat decimalFormat = new DecimalFormat("####0.0", new DecimalFormatSymbols(Locale.ENGLISH));

/**
* Helper inner class to store a Condition with a calculated description.
Expand Down

0 comments on commit 64cf80e

Please sign in to comment.