He-Pin commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2166232009


##########
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") {
       clazz
     } else {
       throw new ClassNotFoundException(
-        s"Class rejected: ${objectStreamClass.getName()} (only primitive types 
and subclasses of java.lang.Number are allowed)")
+        s"Class rejected: ${objectStreamClass.getName()} " +
+        "(only primitive types, arrays of primitive types, subclasses of 
java.lang.Number " +

Review Comment:
   And it's been used in `Metric#convertNumber`



-- 
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: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to