Skip to content

HIVE-29521: Unit tests TestTimestampTZ, TestTimestampTZWritable fail due to different JDK locale#6388

Merged
soumyakanti3578 merged 2 commits into
apache:masterfrom
hemanthumashankar0511:timestamp_failures_fix
Mar 31, 2026
Merged

HIVE-29521: Unit tests TestTimestampTZ, TestTimestampTZWritable fail due to different JDK locale#6388
soumyakanti3578 merged 2 commits into
apache:masterfrom
hemanthumashankar0511:timestamp_failures_fix

Conversation

@hemanthumashankar0511

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?
This PR stabilizes the static FORMATTER in TimestampTZUtil.java by explicitly setting its locale to Locale.US.

Changes:

Added import java.util.Locale;.

Updated FORMATTER initialization to use builder.toFormatter(Locale.US) instead of the default toFormatter().

Why are the changes needed?
The changes are required to fix a DateTimeParseException observed in "Canary" and modern CI environments (JDK 17/21).

Without an explicit locale, DateTimeFormatter falls back to the system's default locale. In certain environments specifically those using the CLDR (Unicode Common Locale Data Repository) provider—the default locale's rules for parsing timezone identifiers can lead to "greedy" matching. This causes the parser to match the "UTC" string and stop, leaving the offset (e.g., +08:00) as unparsed text, resulting in a failure at index 23.

Hardcoding Locale.US ensures that the parsing logic is deterministic and consistent across all developer machines and build servers, regardless of their local system configuration.

Does this PR introduce any user-facing change?
No. This is an internal fix for parsing consistency. The behavior for users remains the same, but the reliability of parsing existing timestamp formats is improved across different server locales.

How was this patch tested?
The patch was verified using the following steps:

Reproduction: Confirmed that org.apache.hadoop.hive.common.type.TestTimestampTZ fails when running with the CLDR provider enabled:
mvn test -Dtest=TestTimestampTZ -DargLine="-Djava.locale.providers=CLDR"

Verification: Confirmed that after adding Locale.US, the tests pass successfully under the same CLDR provider settings.

Regression: Verified TestTimestampTZWritable (in serde) passes to ensure no serialization regressions.

@sonarqubecloud

Copy link
Copy Markdown

@soumyakanti3578 soumyakanti3578 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hemanthumashankar0511

Copy link
Copy Markdown
Contributor Author

@soumyakanti3578 Could u please merge this !!

@soumyakanti3578 soumyakanti3578 merged commit 8868601 into apache:master Mar 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants