He-Pin commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2165440113
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/protobuf/NumberInputStream.scala:
##########
@@ -32,24 +33,28 @@ import pekko.annotation.InternalApi
@InternalApi
private[protobuf] class NumberInputStream(
classLoader: ClassLoader,
- inputStream: InputStream) extends ObjectInputStream(inputStream) {
+ inputStream: InputStream) extends
ClassLoaderObjectInputStream(classLoader, inputStream) {
/**
* Resolve a class specified by the descriptor using the provided classloader
- * and that treats any class that is not a primitive or a subclass of
- * <code>java.lang.Number</code> as not found.
+ * and that treats any class that is not a primitive, an array of primitives
+ * or a subclass of <code>java.lang.Number</code>
+ * or <code>java.math</code> classes as not found.
*
* @param objectStreamClass descriptor of the class
* @return the Class object described by the ObjectStreamClass
* @throws ClassNotFoundException if the Class cannot be found (or is
rejected)
*/
override protected def resolveClass(objectStreamClass: ObjectStreamClass):
Class[_] = {
- val clazz = Class.forName(objectStreamClass.getName(), false, classLoader)
- if (clazz.isPrimitive() || classOf[Number].isAssignableFrom(clazz)) {
+ val clazz = super.resolveClass(objectStreamClass)
+ if (clazz.isPrimitive() || (clazz.isArray() &&
clazz.getComponentType.isPrimitive) ||
+ classOf[Number].isAssignableFrom(clazz) || clazz.getPackage.getName ==
"java.math") {
Review Comment:
I think we should just convert the Scala's BigInt and Java's BigInteger and
bigdecimal to primitive value, not sure why Scala's BigInt and BigDecimal is
not a problem
--
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]