Skip to content

fix(core): format the graph space storage percentage with Locale.ROOT - #3216

Merged
imbajin merged 2 commits into
apache:masterfrom
SebastianGruza:fix/graphspace-locale
Sep 17, 2026
Merged

imbajin merged 2 commits into
apache:masterfrom
SebastianGruza:fix/graphspace-locale

Conversation

@SebastianGruza

Copy link
Copy Markdown
Contributor

Purpose of the PR

GraphSpace.info() formats the storage percentage with String.format("%.2f", …) and parses it back with Float.parseFloat. Without a Locale the format follows the JVM default locale, so on pl_PL, de_DE, fr_FR, ru_RU and every other decimal-comma locale it yields "0,33", which parseFloat rejects. Since info() runs on every serialisation of a GraphSpace, with usePD=true a fresh PD makes the Server exit at startup (Can't write json: For input string: "0,00"), an existing PD lets it start degraded (some graphs never load, every drop fails), and GET /graphspaces/{space} answers 400.

Main Changes

  • GraphSpace.info() formats with Locale.ROOT; the arithmetic and the two-digit rounding are unchanged.
  • New unit/core/GraphSpaceInfoLocaleTest (in UnitTestSuite): storage_percent is 0.33 for 33/100 under pl_PL, de_DE, fr_FR, ru_RU and under Locale.ROOT and en_US; the default locale is restored in finally.

Verifying these changes

  • GraphSpaceInfoLocaleTest 2/2 on JDK 11.
  • On a 3-VM lab (1 PD + 3 Store + 1 Server from a tarball, usePD=true, Server JVM started with -Duser.language=pl -Duser.country=PL against a PD that already holds the DEFAULT space): master fabe0f0bGET /graphspaces/DEFAULT answers 400 Can't write json: For input string: "0,00"; this PR → 200 with the full space description. Logs in results/f10-fix/ of https://github.com/SebastianGruza/hugegraph-validation.

GraphSpace.info() formats the storage percentage with String.format and
parses it back with Float.parseFloat. Without a Locale the format follows
the JVM default, so on pl_PL, de_DE, fr_FR, ru_RU and other decimal-comma
locales it yields "0,33", which parseFloat rejects: with usePD=true a
fresh PD makes the server exit at startup (Can't write json: For input
string: "0,00"), an existing PD lets it start degraded (some graphs never
load, every drop fails), and GET /graphspaces/{space} answers 400.
Locale.ROOT keeps the arithmetic and the two-digit rounding unchanged.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.15%. Comparing base (fabe0f0) to head (c3adb36).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3216      +/-   ##
============================================
+ Coverage     41.13%   41.15%   +0.01%     
- Complexity     7212     7215       +3     
============================================
  Files           802      802              
  Lines         69393    69393              
  Branches       9237     9237              
============================================
+ Hits          28546    28556      +10     
+ Misses        37583    37580       -3     
+ Partials       3264     3257       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

🟢 Approval recommended

No unresolved issues were identified that would block approval.

Pull request overview

Fixes locale-dependent GraphSpace.info() serialization for decimal-comma JVM locales.

Changes:

  • Uses Locale.ROOT for storage percentage formatting.
  • Adds locale regression tests and registers them in UnitTestSuite.
File summaries
File Description
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/UnitTestSuite.java Updated as part of this pull request.
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/core/GraphSpaceInfoLocaleTest.java Updated as part of this pull request.
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java Updated as part of this pull request.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

imbajin
imbajin previously approved these changes Sep 17, 2026

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1. Review score: 9.5/10. Two independent global reviews and an adversarial review found no actionable issues at f8bdb84. The Locale.ROOT change fixes locale-dependent serialization while preserving the existing arithmetic and rounding.

Locally verified on Java 11: GraphSpaceInfoLocaleTest passes both tests across the six covered locales; the reactor build succeeds. All 24 checks are green on this exact head. No additional code changes are needed. I did not independently rerun the author's full distributed startup experiment.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blocking: no. Summary: The production fix is correct, but the new locale regression test can leak category-specific JVM locale state into later tests. Evidence: Locale.setDefault(locale) updates the FORMAT and DISPLAY defaults; the test saves only Locale.getDefault() and restores both categories from that one value.

@imbajin
imbajin merged commit 4dc311b into apache:master Sep 17, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] usePD=true breaks on a JVM whose default locale uses a decimal comma (GraphSpace.info() formats "0,00")

3 participants