Skip to content

[fix][misc] Preserve the sign of negative fractions in text output - #26662

Open
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/negative-fraction-format-20260920
Open

hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/negative-fraction-format-20260920

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

Motivation

SimpleTextOutputStream.write(-0.5) produces 0.500: casting the value to long loses the sign when the integer part is zero. The formatter is shared by stats and Prometheus output, so negative fractional values can be reported as positive.

Modifications

Write the minus sign when a negative value has a zero integer part. Keep the existing fractional precision and truncation, and add cases covering negative fractions, positive fractions, and values that truncate to zero.

Verifying this change

  • The four new negative cases fail before the fix.
  • All 12 cases in SimpleTextOutputStreamTest pass after the fix, compiled with JDK 21 (--release 17) and run directly with TestNG 7.12.0 and cached Netty 4.2.16.Final dependencies. The full broker module suite was not run.
  • ./gradlew quickCheck passes.
  • git diff --check passes.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Assisted by OpenAI Codex.

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.

1 participant