-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[LOG4J2-3805] NamedInstantPatternTest#compatibilityOfLegacyPattern fails in timezones with minute offsets (e.g., GMT+05:30) #3888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…imezone offsets The compatibilityOfLegacyPattern test fails in environments where the system default timezone has a non-zero minute offset (e.g., Asia/Kolkata, Asia/Kathmandu). Root cause: - SimpleDateFormat's X pattern truncates fractional offsets (e.g., +05:30 → +05). - DateTimeFormatter's X pattern preserves the minutes (+05:30). Since Log4j intentionally follows DateTimeFormatter’s behavior, the test should not assert equivalence in such environments. This change adds an assumption to skip the test when the system timezone offset is not a whole hour. This ensures deterministic builds for contributors in all regions, while still verifying correctness in whole-hour zones. Closes apache#3805
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ramanathan1504,
Could you move the assumption to the beginning of the test, so it is easier to follow?
...j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/NamedInstantPatternTest.java
Outdated
Show resolved
Hide resolved
…ault zone Ensure legacy and modern formatting produce consistent results when the system default zone offset is a whole hour. Skip the test otherwise using assumptions.
|
@ramanathan1504, thanks! 💯 Since the legacy formatter was removed in |
Thanks |
The compatibilityOfLegacyPattern test fails in timezones with fractional offsets
(e.g., Asia/Kolkata). This happens because SimpleDateFormat truncates fractional
offsets (+05:30 → +05) while DateTimeFormatter preserves them.
This change skips the test in such environments, ensuring consistent builds.
fix #3885