pjfanning commented on code in PR #3382:
URL: https://github.com/apache/pekko/pull/3382#discussion_r3650500972
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/Metric.scala:
##########
@@ -271,13 +271,15 @@ private[metrics] trait MetricNumericConverter {
* May involve rounding or truncation.
*/
def convertNumber(from: Any): Either[Long, Double] = from match {
- case n: Int => Left(n)
- case n: Long => Left(n)
- case n: Double => Right(n)
- case n: Float => Right(n)
- case n: BigInt => Left(n.longValue)
- case n: BigDecimal => Right(n.doubleValue)
- case x => throw new IllegalArgumentException(s"Not a number
[$x]")
+ case n: Int => Left(n)
+ case n: Long => Left(n)
+ case n: Double => Right(n)
+ case n: Float => Right(n)
+ case n: java.math.BigInteger => Left(n.longValue)
+ case n: java.math.BigDecimal => Right(n.doubleValue)
Review Comment:
Short and Byte are numbers - just match against java.lang.Number and call
longValue or doubleValue on it - do this before the `case x` and leave the
existing specialised matches
--
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]