Search code examples
javacharacter-encodinglocalizationgitlablocale

Java character encoding discrepancies on Gitlab


I'm seeing the behavior where my code running locally produces characters different from when it's running in the Gitlab staging pipeline triggering the associated failure of the tests. Specifically,

Here's the output I'm seeing in my local environment: enter image description here

and here's the one from staging:

enter image description here

looks like tests on the staging box are misinterpreting the $ formatting somehow, and the $ character gets replaced with ¤

Here's the associated Java code, I'm obtaining the default locale to formulate the message:

return new String[] { headerLine.toString(),
                "Date: " + tx.getTransactionDate().getDate().toString() + "\nAmount: "

                        + NumberFormat.getCurrencyInstance(Locale.getDefault()).format(tx.getAmount()) + "\nAccount: "
                        + (accumulatedInputs.get(FIELD_ACTNUM) != null
                                ? accumulatedInputs.get(FIELD_ACTNUM).value
                                : accumulatedInputs.get(TransactionInquiryIntentProcessor.FIELD_REFNUM).value)
                        + "\n" + subTitleBuilder.toString() };

Not sure what could be wrong in that staging environment?


Solution

  • We ended up having our DevOps team explicitly specifying en_US locale in Kubernetes which fixed the issue.