Skip to content

Conversation

ramanathan1504
Copy link
Contributor

@ramanathan1504 ramanathan1504 commented Aug 19, 2025

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

…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
@ramanathan1504 ramanathan1504 changed the title [LOG4J2-3805] Skip compatibilityOfLegacyPattern test for fractional timezone offsets [LOG4J2-3805] NamedInstantPatternTest#compatibilityOfLegacyPattern fails in timezones with minute offsets (e.g., GMT+05:30) Aug 19, 2025
@ppkarwasz ppkarwasz moved this from To triage to Ready in Log4j bug tracker Aug 19, 2025
Copy link

github-actions bot commented Aug 19, 2025

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

Copy link
Contributor

@ppkarwasz ppkarwasz left a 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?

…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 ramanathan1504 deleted the issue-3885 branch August 21, 2025 11:41
@github-project-automation github-project-automation bot moved this from Ready to Done in Log4j bug tracker Aug 21, 2025
@ramanathan1504 ramanathan1504 restored the issue-3885 branch August 21, 2025 11:43
@github-project-automation github-project-automation bot moved this from Done to Waiting for user in Log4j bug tracker Aug 21, 2025
@ramanathan1504
Copy link
Contributor Author

@ppkarwasz

⚠️ Note:
A previous commit/branch was mistakenly deleted. It has now been restored correctly.
All intended changes are present, and this PR is ready for review.
Thank you for your understanding.

@ppkarwasz ppkarwasz enabled auto-merge (squash) August 21, 2025 20:12
@ppkarwasz
Copy link
Contributor

@ramanathan1504, thanks! 💯

Since the legacy formatter was removed in main, this PR does not need to be ported.

@ppkarwasz ppkarwasz merged commit 769b924 into apache:2.x Aug 21, 2025
17 checks passed
@github-project-automation github-project-automation bot moved this from Waiting for user to Done in Log4j bug tracker Aug 21, 2025
@ramanathan1504 ramanathan1504 deleted the issue-3885 branch August 22, 2025 00:02
@ramanathan1504
Copy link
Contributor Author

@ppkarwasz

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

NamedInstantPatternTest#compatibilityOfLegacyPattern fails in timezones with minute offsets (e.g., GMT+05:30)

2 participants