You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/03/16 00:27:53 UTC

[GitHub] [logging-log4j2] LF-Lin opened a new pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

LF-Lin opened a new pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800


   This PR fixes the [issue](https://issues.apache.org/jira/browse/LOG4J2-3019) 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:
   ```
   Windows display language: zh_CN
   Regional format: en_NL
   ```
   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 
   - the actual value that generated from `layout` at [line 255](https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java#L255) using `Locale.getDefault()` (zh_CN, which causes `02 十一月`), 
   - the expected value that generated from `DateTimeFormatter.ofPattern()` at [line 269](https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java#L269) using `Locale.Category.FORMAT` (en_NL, which causes `02 Nov`). 
    
   It is easy to avoid this issue by manually setting the `locale` argument for `DateTimeFormatter.ofPattern()`, and the results will use the `Locale.getDefault()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory commented on pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800#issuecomment-1069217637


   Closing, per @LF-Lin 's comment.
   TY!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] LF-Lin commented on pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

Posted by GitBox <gi...@apache.org>.
LF-Lin commented on pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800#issuecomment-1069149812


   > Hi @LF-Lin Thank you for your PR. In order to make this use-case more obvious in the test, I choose a different implementation; please pull the branch and try your local build. Let us know what your results are. TY!
   
   Nice implementation. Test passes! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory commented on pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800#issuecomment-1069089222


   Hi @LF-Lin 
   Thank you for your PR. In order to make this use-case more obvious in the test, I choose a different implementation; please pull the branch and try your local build. Let us know what your results are.
   TY!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] LF-Lin commented on pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

Posted by GitBox <gi...@apache.org>.
LF-Lin commented on pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800#issuecomment-1068601032


   Also, I reproduced the result in this [issue](https://issues.apache.org/jira/browse/LOG4J2-3019) by adding the following lines in [testLayoutWithDatePatternFixedFormat()](https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java#L239),
   ```java
   Locale.setDefault(new Locale("en", "NL"));  // en_NL --> 02 Nov
   Locale.setDefault(Locale.Category.FORMAT, new Locale("nl", "NL"));  // nl_NL --> 02 nov
   ```
   the result will be: `[ERROR]   HtmlLayoutTest.testLayoutWithDatePatternFixedFormat:242->testLayoutWithDatePatternFixedFormat:273 Incorrect date=<td>02 Nov 2012 21:34:02,123</td>, format=DATE, timezone=GMT+8 ==> expected: <<td>02 nov 2012 21:34:02,123</td>> but was: <<td>02 Nov 2012 21:34:02,123</td>> `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory closed pull request #800: LOG4J2-3019: Fix HtmlLayoutTest on Windows

Posted by GitBox <gi...@apache.org>.
garydgregory closed pull request #800:
URL: https://github.com/apache/logging-log4j2/pull/800


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org