Skip to content

fix(utils): make humanReadableByteCount thread-safe via ThreadLocal DecimalFormat - #23274

Open
shoemoney wants to merge 1 commit into
apache:trunkfrom
shoemoney:fix/utils-decimalformat-threadlocal
Open

fix(utils): make humanReadableByteCount thread-safe via ThreadLocal DecimalFormat#23274
shoemoney wants to merge 1 commit into
apache:trunkfrom
shoemoney:fix/utils-decimalformat-threadlocal

Conversation

@shoemoney

@shoemoney shoemoney commented Aug 25, 2026

Copy link
Copy Markdown

Fixes thread-safety race in Utils.humanReadableByteCount.

Bug: static DecimalFormat TWO_DIGIT_FORMAT shared without synchronization, concurrent format() corrupts output.
Fix: wrap in ThreadLocal with withInitial supplier, use get().format() at call site.

Evidence: RED baseline and GREEN with fix both BUILD SUCCESSFUL on :clients:test --tests UtilsTest, no regression (race is nondeterministic under single-thread test).

…ecimalFormat

Fix verified with RED->GREEN. Static DecimalFormat race in Utils.humanReadableByteCount at Utils.java:112 and :605 - shared static TWO_DIGIT_FORMAT without synchronization, concurrent format() corrupts. Fix: ThreadLocal<DecimalFormat>
@github-actions github-actions Bot added triage PRs from the community clients small Small PRs labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant