He-Pin opened a new pull request, #3382:
URL: https://github.com/apache/pekko/pull/3382

   ### 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"` — All 7 tests 
passed
   - `sbt "cluster-metrics / Test / testOnly 
org.apache.pekko.cluster.metrics.protobuf.MessageSerializerSpec"` — All 2 tests 
passed
   
   ### References
   None - discovered during Java API audit for Scala number type usage


-- 
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]


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

Reply via email to