nikolauspschuetz opened a new pull request, #22921:
URL: https://github.com/apache/kafka/pull/22921

   `Utils.formatBytes(0)` returns `"0.0"` instead of `"0 B"`.
   
   For `bytes == 0`, `Math.log(0)` is `-Infinity`, so the scale `ordinal` 
underflows to `Integer.MIN_VALUE`, the `BYTE_SCALE_SUFFIXES[ordinal]` lookup 
throws `ArrayIndexOutOfBoundsException`, and the `catch` falls back to 
`String.valueOf(0.0)`. Zero is neither negative nor "too large", so it is an 
unintended path. `formatBytes` is used by 
`SimpleMemoryPool`/`GarbageCollectedMemoryPool` `toString()`, so an empty pool 
renders `0.0` in operator-facing output.
   
   Structured red→green, verified in a JDK17 container (`./gradlew clients:test 
--tests UtilsTest.testFormatBytes`):
   - **1st commit** adds the regression test — **FAILED**: `expected: <0 B> but 
was: <0.0>`
   - **2nd commit** applies the fix — **PASSED**
   
   Trivial one-value correction, no public API change → `MINOR` (no JIRA/KIP).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to