pulsar
pulsar copied to clipboard
[fix][cli] Reject overflowing byte-size values
Motivation
ByteUnitUtil.validateSizeString parsed the numeric part as a long, then multiplied by the selected unit using normal arithmetic. Inputs such as 9223372036854775807K could overflow during unit conversion instead of being rejected as invalid.
Modifications
- Use
Math.multiplyExactwhen applying byte-size unit multipliers. - Keep invalid size errors consistent for parse failures and overflow failures.
- Add a regression case for a long overflow input.
Verifying this change
git diff --check- Not run:
./gradlew :pulsar-cli-utils:test --tests org.apache.pulsar.cli.converters.ByteConversionTestbecause this environment has no Java Runtime available.