LOG4J2-3019: Fix HtmlLayoutTest on Windows #800
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the issue that
HtmlLayoutTest.testLayoutWithDatePatternFixedFormat
test fails on Windows.AFAIK, this test only fails in a special case on Windows, that is, the Windows display language and Regional format are inconsistent. For example, my settings are:
the result will be:
[ERROR] HtmlLayoutTest.testLayoutWithDatePatternFixedFormat:245->testLayoutWithDatePatternFixedFormat:277 Incorrect date=<td>02 十一月 2012 21:34:02,123</td>, format=DATE, timezone=GMT+8 ==> expected: <<td>02 Nov 2012 21:32,123</td>> but was: <<td>02 十一月 2012 21:34:02,123</td>>
I think the reason is that
layout
at line 255 usingLocale.getDefault()
(zh_CN, which causes02 十一月
),DateTimeFormatter.ofPattern()
at line 269 usingLocale.Category.FORMAT
(en_NL, which causes02 Nov
).It is easy to avoid this issue by manually setting the
locale
argument forDateTimeFormatter.ofPattern()
, and the results will use theLocale.getDefault()
.