RFR: 8265828: [TestBug] Save and restore the default Locale in javafx.base unit test LocalDateTimeStringConverterTest

Lukasz Kostyra duke at openjdk.org
Fri Nov 18 17:02:42 UTC 2022


On Fri, 18 Nov 2022 16:17:55 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> modules/javafx.base/src/test/java/test/javafx/util/converter/LocalDateTimeStringConverterTest.java line 60:
>> 
>>> 58:     private static final DateTimeFormatter aFormatter = DateTimeFormatter.ofPattern("dd MM yyyy HH mm ss");
>>> 59:     private static final DateTimeFormatter aParser = DateTimeFormatter.ofPattern("yyyy MM dd hh mm ss a");
>>> 60:     private static Locale oldLocale;
>> 
>> Isn't the creation of the DateTimeFormatter using the default locale? If so, this should probably be done after the locale is set.
>
> This is a good point. Moving the initialization of those two fields to the `setupBeforeAll` method seems safest.

That is a fair point.

I'll have to change the code a bit, as `implementations()` method is called before a `@BeforeClass`-tagged method (which is probably why originally `Locale.setDefault()` was called there) and `aFormatter`/`aParser` are already used there, expected to be initialized.

-------------

PR: https://git.openjdk.org/jfx/pull/954


More information about the openjfx-dev mailing list