You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2025/06/19 20:42:32 UTC
[PR] try to fix broken cluster metrics test [pekko]
pjfanning opened a new pull request, #1912:
URL: https://github.com/apache/pekko/pull/1912
* see #1911
* the CI changes are temporary - just to test the PR
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2158464094
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/protobuf/NumberInputStream.scala:
##########
@@ -32,20 +33,21 @@ 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> 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)) {
Review Comment:
Good points. I added extra tests and found another issue.
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/protobuf/NumberInputStream.scala:
##########
@@ -32,20 +33,21 @@ 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> 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)) {
Review Comment:
Good points. I added extra tests and found another issue. Now fixed.
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2165443282
##########
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:
How about the Scala number (ScalaNumber), @pjfanning
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2157930408
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/protobuf/NumberInputStream.scala:
##########
@@ -32,20 +33,21 @@ 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> 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)) {
Review Comment:
1. we should fix the error messages too, at line 54
2. add a test for BigDecimal and BigInteger cases?
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2166204955
##########
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:
I am not familiar with that class. I can't find it in the Scala docs.
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2160315594
##########
cluster-metrics/src/main/scala/org/apache/pekko/cluster/metrics/protobuf/NumberInputStream.scala:
##########
@@ -32,20 +33,21 @@ 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> 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)) {
Review Comment:
@He-Pin would you be able to review this again if you have time?
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1912:
URL: https://github.com/apache/pekko/pull/1912
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] try to fix broken cluster metrics test [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #1912:
URL: https://github.com/apache/pekko/pull/1912#discussion_r2166230602
##########
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:
`scala.math.ScalaNumber`
<img width="809" alt="image" src="https://github.com/user-attachments/assets/6371c493-0020-48e1-8957-751600b8c57a" />
I see, it extends the java.lang.numbers.
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org