> This PR fixes an intermittent failure (that only occurs on Windows) in > _DateFormatRegression.java_. > > With the integration of > [JDK-8304982](https://bugs.openjdk.org/browse/JDK-8304982), > _LocaleProviderAdapter.java_ now emits a compat warning when the class is > loaded. This warning calls `ZonedDateTime.now()` during formatting. This call > depends on the `TimeZone.ID` of the TimeZone returned from > `TimeZone.getDefault()`. > > On Windows, the test class which DateFormatRegression extends will run the > tests at random, (as opposed to running in the same order every time). When > Test4089106() happens to be the first test ran, the static block of > LocaleProviderAdapter will be executed with `TimeZone.setDefault()` set to a > `SimpleTimeZone` with `id` as _FAKEZONE_. When LocaleProviderAdapter formats > the compat warning ... and many calls later calls `ZoneRulesProvider > getProvider(String zoneId)` with `zoneId` as _FAKEZONE_ the test fails with > _java.time.zone.ZoneRulesException: Unknown time-zone ID: FAKEZONE_. > > In order to still test that `SimpleDateFormat.getTimeZone()` defaults to > `TimeZone.getDefault()` we can create a `SimpleTimeZone` with a custom id > rather than an invalid id. This way ZoneRulesProvider will not fail on the > ID, but the `SimpleTimeZone` being tested is still not a "default" `TimeZone`.
Justin Lu has updated the pull request incrementally with one additional commit since the last revision: Minor cleanup / alternate custom tz ------------- Changes: - all: https://git.openjdk.org/jdk/pull/13630/files - new: https://git.openjdk.org/jdk/pull/13630/files/348f9691..19973c31 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=13630&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13630&range=00-01 Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/13630.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/13630/head:pull/13630 PR: https://git.openjdk.org/jdk/pull/13630