The GitHub Actions job "Nightly Builds (1.7)" on pekko.git/main has failed.
Run started by GitHub user pjfanning (triggered by pjfanning).

Head commit for run:
2408ac01402b119010ca9b434680bb04305ac27a / He-Pin(kerr) <[email protected]>
fix: support java.math.BigInteger/BigDecimal in MetricNumericConverter (#3382)

* fix: support java.math.BigInteger/BigDecimal in MetricNumericConverter

Motivation:
MetricNumericConverter.convertNumber only handled scala.math.BigInt and
scala.math.BigDecimal but not java.math.BigInteger and java.math.BigDecimal.
Since Metric.value is typed as java.lang.Number, Java users passing
java.math.BigInteger or java.math.BigDecimal would get an
IllegalArgumentException. The NumberInputStream deserializer also explicitly
allows java.math classes through, so deserialized values could also fail.

Modification:
Add pattern match cases for java.math.BigInteger and java.math.BigDecimal in
convertNumber, placed before the Scala BigInt/BigDecimal cases.

Result:
Java users can now use java.math.BigInteger and java.math.BigDecimal as
Metric values without errors.

Tests:
- sbt "cluster-metrics / Test / testOnly 
org.apache.pekko.cluster.metrics.MetricNumericConverterSpec"
- sbt "cluster-metrics / Test / testOnly 
org.apache.pekko.cluster.metrics.protobuf.MessageSerializerSpec"
- All tests passed.

References:
None - discovered during Java API audit for Scala number type usage

* fix: support any Number subtype in MetricNumericConverter and 
MessageSerializer

Motivation:
Metric.value is typed as java.lang.Number, so any Number subtype should
be accepted without throwing. Previously only Int/Long/Double/Float/BigInt/
BigDecimal were handled; other Number subtypes (Short, Byte, AtomicInteger,
AtomicLong, java.math.BigInteger) would throw IllegalArgumentException.
Additionally, BigInt/BigDecimal fell through to Java ObjectOutputStream
serialization in numberToProto, which is inefficient and a security concern.

Modification:
- Add generic `case n: Number => Left(n.longValue)` catch-all in
  convertNumber, with java.math.BigDecimal kept explicit (needs doubleValue)
- Add BigInt/BigDecimal/java.math.BigDecimal and generic Number cases in
  numberToProto to use efficient protobuf encoding (Long/Double) instead of
  Java serialization fallback
- Expand tests to cover Short, Byte, AtomicInteger, AtomicLong, BigDecimal,
  java.math.BigInteger, java.math.BigDecimal round-trip serialization

Result:
Any java.lang.Number subtype is now accepted as a Metric value. Serialization
uses efficient protobuf encoding for all Number types, eliminating Java
ObjectOutputStream usage for known numeric types.

Tests:
- sbt "cluster-metrics / Test / test" — All 59 tests passed

References:
Refs #3385

Report URL: https://github.com/apache/pekko/actions/runs/30181956368

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to