You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2025/10/27 14:27:31 UTC
(pekko) 01/01: chore: opt serializerFor (#2395)
This is an automated email from the ASF dual-hosted git repository.
hepin pushed a commit to branch 1.3.x-seria
in repository https://gitbox.apache.org/repos/asf/pekko.git
commit 84b4d639362d1be8d06f467a346843ef7c548118
Author: He-Pin(kerr) <he...@gmail.com>
AuthorDate: Mon Oct 27 22:25:57 2025 +0800
chore: opt serializerFor (#2395)
(cherry picked from commit d0be463fa14135260b7d0ff103e315de4c9a1234)
---
.../org/apache/pekko/serialization/Serialization.scala | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala b/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala
index 30609b7e79..b823597437 100644
--- a/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala
+++ b/actor/src/main/scala/org/apache/pekko/serialization/Serialization.scala
@@ -36,6 +36,7 @@ import pekko.util.ccompat._
@ccompatUsedUntil213
object Serialization {
+ private final val PekkoPackagePrefix = "org.apache.pekko."
/**
* Tuple that represents mapping from Class to Serializer
@@ -318,9 +319,11 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
serializerMap.get(clazz) match {
case null => // bindings are ordered from most specific to least specific
def unique(possibilities: immutable.Seq[(Class[_], Serializer)]): Boolean =
- possibilities.size == 1 ||
- (possibilities.forall(_._1.isAssignableFrom(possibilities(0)._1))) ||
- (possibilities.forall(_._2 == possibilities(0)._2))
+ possibilities.size == 1 || {
+ val possibility = possibilities.head
+ possibilities.forall(_._1.isAssignableFrom(possibility._1)) ||
+ possibilities.forall(_._2 == possibility._2)
+ }
val ser = {
bindings.filter {
@@ -467,13 +470,14 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
}
private def warnUnexpectedNonPekkoSerializer(clazz: Class[_], ser: Serializer): Boolean = {
- if (clazz.getName.startsWith("org.apache.pekko.") && !ser.getClass.getName.startsWith("org.apache.pekko.")) {
+ val clazzName = clazz.getName
+ if (clazzName.startsWith(PekkoPackagePrefix) && !ser.getClass.getName.startsWith(PekkoPackagePrefix)) {
log.warning(
"Using serializer [{}] for message [{}]. Note that this serializer " +
"is not implemented by Apache Pekko. It's not recommended to replace serializers for messages " +
"provided by Apache Pekko.",
ser.getClass.getName,
- clazz.getName)
+ clazzName)
true
} else false
}
@@ -574,7 +578,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
isJavaSerializationWarningEnabled &&
(serializer.isInstanceOf[JavaSerializer] || serializer.isInstanceOf[DisabledJavaSerializer]) &&
- !serializedClass.getName.startsWith("org.apache.pekko.") &&
+ !serializedClass.getName.startsWith(PekkoPackagePrefix) &&
!serializedClass.getName.startsWith("java.lang.") &&
!suppressWarningOnNonSerializationVerification(serializedClass)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org