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

Julian Hyde commented on CALCITE-6580:
--------------------------------------

If the production code doesn't depend on the default locale, what's the point 
in changing it during tests? The most likely effect is to screw up other tests. 
So your point is moot. Let's remove it everywhere.

Specifically, let's add {{Locale}} as a constructor parameter of 
{{PostgresqlDateTimeFormatter}}, and let's make the {{toChar}} method 
non-{{static}}.

There's an opportunity to make those {{PostgresDateTimeFormatter}} tests less 
verbose, because

{code}
try {
  Locale.setDefault(x);
  assertEquals("12", PostgresDateTimeFormatter.toChar(pattern, midmight));
  assertEquals("06", PostgresDateTimeFormatter.toChar(pattern, morning));
finally {
  Locale.setDefault(previous);
}
{code}

becomes

{code}
PostgresDateTimeFormatter f = PostgresDateTimeFormatter.of(x);
assertThat(f.toChar(pattern, midnight), is("12"));
assertThat(f.toChar(pattern, morning), is("06"));
{code}


> 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
>
> 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