[ 
https://issues.apache.org/jira/browse/CALCITE-6580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881693#comment-17881693
 ] 

Norman Jordan edited comment on CALCITE-6580 at 9/13/24 9:20 PM:
-----------------------------------------------------------------

PostgreSQL will use English as the language unless translate mode is used for a 
date/time pattern. This means that in almost all cases, we do not depend on the 
locale and the tests do not need to set the default locale.

A PostgreSQL date/time pattern can use translate mode. To enable translate mode 
for the pattern "DAY", use "TMDAY". "TMDAY" will output the name of the day for 
the current locale in all uppercase.

I want to have tests for the translate mode. There are a couple of solutions:
 * Run the entire unit test suite again with a different locale
 * Isolate the class that changes the locale with the "@Isolated" annotation 
(org.junit.jupiter.api.parallel.Isolated).

Is this up for discussion or is "Locale.setDefault" absolutely forbidden in 
tests?


was (Author: njordan):
PostgreSQL will use English as the language unless translate mode is used for a 
date/time pattern. This means that in almost all cases, we do not depend on the 
locale and the tests do not need to set the default locale.

A PostgreSQL date/time pattern can use translate mode. To enable translate mode 
for the pattern "DAY", use "TMDAY". "TMDAY" will output the name of the day for 
the default locale in all uppercase.

I want to have tests for the translate mode. There are a couple of solutions:
 * Run the entire unit test suite again with a different locale
 * Isolate the class that changes the locale with the "@Isolated" annotation 
(org.junit.jupiter.api.parallel.Isolated).

Is this up for discussion or is "Locale.setDefault" absolutely forbidden in 
tests?

> Remove Locale.setDefault
> ------------------------
>
>                 Key: CALCITE-6580
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6580
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Julian Hyde
>            Priority: Major
>              Labels: pull-request-available
>
> Remove all calls to {{Locale.setDefault}} in tests and production code.
> That function does not operate on the current thread; it affects all threads 
> in the JVM. As such, it may affect other tests running at the same time, and 
> affect other statements running at the same time.
> I hope, and believe, that the production code does not depend on 
> {{Locale.getDefault}}. But let's make sure by removing {{setDefault}} from 
> all tests.
> Add {{Locale.setDefault}} to 
> [forbidden-apis|https://github.com/apache/calcite/blob/main/src/main/config/forbidden-apis/signatures.txt].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to