From 2242b873e39bbbaaf5a117bd08deaff0e9b7e630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Veiga=20Ortiz?= Date: Fri, 14 Jul 2023 13:34:11 -0700 Subject: [PATCH] Only instantiate clazz when includeManifest is enabled --- .../akka/serialization/kryo/KryoSerializerBackend.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/akka-kryo-serialization/src/main/scala/io/altoo/akka/serialization/kryo/KryoSerializerBackend.scala b/akka-kryo-serialization/src/main/scala/io/altoo/akka/serialization/kryo/KryoSerializerBackend.scala index c041af8..b34d239 100644 --- a/akka-kryo-serialization/src/main/scala/io/altoo/akka/serialization/kryo/KryoSerializerBackend.scala +++ b/akka-kryo-serialization/src/main/scala/io/altoo/akka/serialization/kryo/KryoSerializerBackend.scala @@ -73,13 +73,13 @@ private[kryo] class KryoSerializerBackend(val kryo: Kryo, val bufferSize: Int, v // Implements ByteBufferSerializer override def fromBinary(buf: ByteBuffer, manifest: String): AnyRef = { val buffer = getInput(buf) - val clazz = system.dynamicAccess.getClassFor[AnyRef](manifest) - if (includeManifest) + if (includeManifest) { + val clazz = system.dynamicAccess.getClassFor[AnyRef](manifest) clazz match { case Success(c) => kryo.readObject(buffer, c).asInstanceOf[AnyRef] case _ => throw new RuntimeException("Object of unknown class cannot be deserialized") } - else + } else kryo.readClassAndObject(buffer) }