Skip to content

[Fix][Zeta] Make job status parsing locale independent - #11894

Merged
davidzollo merged 1 commit into
apache:devfrom
hiSandog:fix/small-correctness-20260820
Aug 30, 2026
Merged

davidzollo merged 1 commit into
apache:devfrom
hiSandog:fix/small-correctness-20260820

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

Purpose of this pull request

JobStatus.fromString currently uppercases status values with the JVM default locale. Under a Turkish default locale, finished becomes FİNİSHED, so JobStatus.valueOf throws an IllegalArgumentException.

This patch uses Locale.ROOT for locale-independent enum parsing and adds a regression test that exercises the Turkish-locale case.

Does this PR introduce any user-facing change?

Yes. Lowercase job status values are now parsed consistently regardless of the JVM default locale. Behavior in locales unaffected by special case mappings remains unchanged.

How was this patch tested?

A regression test was added in JobStatusTest and was verified to fail before the fix with No enum constant ... JobStatus.FİNİSHED.

The following checks pass:

./mvnw -q -pl seatunnel-engine/seatunnel-engine-common -am -Dtest=JobStatusTest -Dsurefire.failIfNoSpecifiedTests=false -Dskip.spotless=true test
./mvnw -q spotless:apply
CYPRESS_INSTALL_BINARY=0 ./mvnw -q -DskipTests verify

CYPRESS_INSTALL_BINARY=0 only skips downloading the Cypress browser binary, which is not used by the -DskipTests verification.

Check list

  • No new Jar binary package is added.
  • Documentation changes are not necessary for this internal parsing correction.
  • This change is backward compatible and does not require an incompatible-changes.md entry.
  • This is not connector code.

@github-actions github-actions Bot added the Zeta label Aug 20, 2026
@goutamadwant

Copy link
Copy Markdown
Collaborator

Looks good to me. Thanks for your contribution!

@DanielLeens DanielLeens 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.

What Problem Does This PR Solve?

JobStatus.fromString(String status) upper-cases the input with String.toUpperCase() (JVM default locale) before calling JobStatus.valueOf(...). Under a Turkish (tr/tr-TR) default JVM locale, Java's well-known locale-sensitive casing rule converts lowercase i to İ (dotted capital I, U+0130) instead of the ASCII I, so "finished".toUpperCase() becomes "FİNİSHED", which doesn't match the enum constant FINISHED — JobStatus.valueOf(...) throws IllegalArgumentException. This PR switches to toUpperCase(Locale.ROOT), the standard fix for exactly this class of bug (locale-independent case conversion for programmatic string matching), and adds a regression test that reproduces the failure under tr-TR.

1. Code Change Review

1.1 Core Logic Analysis

Before: return JobStatus.valueOf(status.toUpperCase());
After: return JobStatus.valueOf(status.toUpperCase(Locale.ROOT));

This is the textbook-correct fix for the "Turkish locale bug" — a genuine, frequently-cited JDK gotcha (not a novel or exotic edge case), and Locale.ROOT is the idiomatic choice here (language-neutral Unicode default rules) rather than hardcoding e.g. Locale.US, which is the pattern recommended by the JDK docs themselves for this exact situation.

Runtime-path check (important — did I verify the normal path actually reaches this code): I searched the entire apache/seatunnel tree (main sources, excluding this PR's own new test) for callers of JobStatus.fromString and JobStatus.valueOf. There are no other callers anywhere in the repository — the only place fromString is invoked is the new JobStatusTest added by this PR itself. So today, no in-tree SeaTunnel job-execution path (CLI, REST, Zeta master/worker, checkpoint/restore, etc.) is affected by this bug, because nothing in-repo currently calls this method. This doesn't make the fix wrong — fromString is a public static method on a public enum in seatunnel-engine-common, which is a library consumed outside this repo (external tooling, SDK users, the web console/other Whale-family products that depend on this jar), so a latent locale bug in a public parsing API is still worth fixing defensively. I just want to be explicit that the practical blast radius today is "public API correctness for external consumers," not "currently-running production job status parsing," since no current in-tree caller exercises it.

1.2 Compatibility Impact

Fully compatible. Locale.ROOT and the JVM default locale produce identical output for every locale except a small set of locale-specific casing exceptions (Turkish i/İ/ı/I, and similarly Azerbaijani; Lithuanian has some dot-related lowercase quirks but not relevant here). For any JVM not running under one of those locales, behavior is byte-for-byte unchanged. No config/API/serialization changes.

1.3 Performance / Side-Effect Analysis

None — same-cost string operation, no new allocations of consequence, no new IO/locking.

1.4 Error Handling and Logging

No issues found. The method's failure mode (IllegalArgumentException from valueOf on a genuinely-unrecognized status string) is unchanged for actually-invalid input; this PR only removes a false-positive failure for the Turkish-locale case.

2. Code Quality Assessment

2.1 Coding Standards

Clean, minimal, single-line fix consistent with the rest of the file. No new public method/field was added that would require a fresh Javadoc.

2.2 Test Coverage and Test Stability

Stable, and notably well-guarded against the exact class of flakiness this kind of test usually introduces. Locale.setDefault(...) mutates process-wide, shared JVM static state — a real risk for test-suite flakiness if another test running concurrently (or afterward) depends on the default locale. The author correctly:

  • Saves Locale.getDefault() before mutating and restores it in a finally block, so the mutation can't leak into other tests even if the assertion fails.
  • Annotates the test with @ResourceLock("default-locale") (JUnit 5), which prevents this test from running concurrently with any other test that also declares the same resource lock — the standard, correct JUnit 5 mechanism for guarding shared global mutable state under parallel test execution. (Note this only protects against other tests that also declare the same lock name; it's a convention-based guard, not an OS-level lock — but it's the right tool and the right usage for this repo's JUnit 5 test setup.)
  • The regression test was verified to fail pre-fix with the exact expected error (No enum constant ... JobStatus.FİNİSHED), per the PR description — good practice, confirms the test actually exercises the bug rather than trivially passing either way.

Rating: Stable.

2.3 Documentation Updates

None included; none required — internal parsing-correctness fix, no user-facing config or behavior contract change.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise, minimal fix — addresses the actual root cause (locale-sensitive case conversion) with the standard idiomatic JDK fix, no over-engineering.

3.2 Maintainability

Trivial to maintain; a one-line change with a test that pins the exact failure mode it prevents.

3.3 Extensibility

N/A for a fix this small.

3.4 Historical-Version Compatibility

No state/checkpoint/serialization impact. Behavior is identical for all locales except the Turkish-family exception, where it goes from "throws" to "works correctly" — a strict improvement, not a semantic change for any currently-working case.

4. Issue Summary

No blocking issues found.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed:
    • CI (environmental, not PR-caused): The fork's Build run (https://github.com/hiSandog/seatunnel/actions/runs/32330154129, head 628c16b0) failed after ~5h19m. I checked the actual failing jobs and none of them touch this PR's code:
      • Run / unit-test (8, windows-latest) — failed at [ERROR] Failed to execute goal on project connector-druid: Could not resolve dependencies ... transfer failed for .../druid-processing-24.0.1.jar: Read timed out — a pure Maven Central network timeout unrelated to seatunnel-engine-common.
      • Run / all-connectors-it-7 (11, ubuntu-latest) and Run / doris-connector-it (11, ubuntu-latest) — unrelated connector/IT modules this PR doesn't touch.
        This is textbook CI infrastructure flake, not a real failure introduced by this diff (a 2-file change confined to seatunnel-engine-common's JobStatus.java/JobStatusTest.java). Recommended next step: re-run the failed jobs (Run / unit-test (8, windows-latest), Run / all-connectors-it-7, Run / doris-connector-it) rather than patching any code.
    • Draft status: this PR is currently marked as a draft — worth converting to "Ready for review" once the CI re-run comes back green, so it can move toward merge.
  2. Recommended fixes — non-blocking: none.

The fix itself is correct, minimal, and well-tested, including a thoughtful guard (@ResourceLock + try/finally) against the shared-global-state flakiness that Locale.setDefault-based tests commonly introduce. Once CI is green (a rerun should suffice — the failures are unrelated infra flake) and the PR is marked ready for review, this looks mergeable as-is. Thanks for tracking down a real, if narrow-blast-radius-today, JDK locale gotcha!

@hiSandog
hiSandog marked this pull request as ready for review August 27, 2026 03:45
@DanielLeens

Copy link
Copy Markdown
Contributor

Following up on my previous review — both blockers I flagged are now resolved as of the current head (628c16b0):

  1. CI: the Build check is now SUCCESS on this exact commit (https://github.com/apache/seatunnel/runs/96309261080), confirming the earlier fork failure was indeed the unrelated Maven-Central/IT infra flake I diagnosed, not something caused by this diff.
  2. Draft status: the PR is no longer a draft.

With both items cleared, my technical conclusion moves from "Ready to merge after fixes" to Ready to merge — I have no remaining blockers from my side. A maintainer with write/approve permission can take it from here to finalize the merge decision. Thanks again for the clean fix!

@DanielLeens DanielLeens 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.

CI-recovery follow-up on this same head (628c16b0).

My 2026-08-20 review concluded "Ready to merge after fixes" with exactly two blockers, both non-code:

  1. CI: the fork's Build run had failed on an unrelated Maven Central network timeout (connector-druid dependency resolution) plus two unrelated connector/IT jobs — diagnosed as infra flake, not caused by this diff.
  2. Draft status: the PR was still marked as a draft.

Both are now cleared:

  • Current CI on this exact head is fully green (Build, Notify test workflow, labeler all pass).
  • The PR is no longer a draft.

No code-level concerns were raised in Section 4 of my original review ("No blocking issues found"), and there have been no new commits since. CI and draft status were the only two things keeping this from merging, so I'm changing my conclusion to Approve.

Thanks again for tracking down a real, if narrow-blast-radius-today, JDK locale gotcha!

@davidzollo davidzollo 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.

+1
LGTM

Thanks for your contribution! This is a solid addition to the project, and your attention to detail really shows. Contributors like you are what keep this community moving forward. Feel free to keep the PRs coming — we're always glad to have you here!

Please ignore the following message if you have joined in the Slack~

To facilitate focused communication among contributors, we’ve created a brand-new dedicated #contributors channel in official Slack workspace.
Slack workspace link: https://s.apache.org/seatunnel-slack

This channel is designed for technical discussions, feature design brainstorming, roadmap sync and direct communication with project core Contributors. Everyone who contributes code, docs, test cases or community ideas is warmly invited to join, share thoughts and collaborate together under The Apache Way. Welcome to join 😄

@davidzollo
davidzollo added this pull request to the merge queue Aug 30, 2026
Merged via the queue into apache:dev with commit d57a0f6 Aug 30, 2026
3 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.

4 participants