From 1a7dda37d20e1bea031c4a425d50617a8d3e61bd Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 30 Mar 2013 02:11:09 +0100 Subject: [PATCH] #3165 - Preventing SOE with conflicting serializers when serialize-messages = on --- .../test/scala/akka/event/LoggerSpec.scala | 30 ++++++++++++++++++- .../src/main/scala/akka/event/Logging.scala | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala b/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala index f153c30649..aa4a82db0f 100644 --- a/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala @@ -9,7 +9,8 @@ import com.typesafe.config.{ Config, ConfigFactory } import akka.actor.{ ActorRef, Actor, ActorSystem } import org.scalatest.WordSpec import org.scalatest.matchers.MustMatchers -import akka.event.Logging.{ LogEvent, LoggerInitialized, InitializeLogger } +import akka.serialization.SerializationExtension +import akka.event.Logging.{ Warning, LogEvent, LoggerInitialized, InitializeLogger } object LoggerSpec { @@ -37,6 +38,21 @@ object LoggerSpec { } """).withFallback(AkkaSpec.testConf) + val ticket3165Config = ConfigFactory.parseString(""" + akka { + stdout-loglevel = "WARNING" + loglevel = "DEBUG" + loggers = ["akka.event.LoggerSpec$TestLogger1"] + actor { + serialize-messages = on + serialization-bindings { + "akka.event.Logging$LogEvent" = bytes + "java.io.Serializable" = java + } + } + } + """).withFallback(AkkaSpec.testConf) + case class SetTarget(ref: ActorRef, qualifier: Int) class TestLogger1 extends TestLogger(1) @@ -127,4 +143,16 @@ class LoggerSpec extends WordSpec with MustMatchers { } } } + + "Ticket 3165 - serialize-messages and dual-entry serialization of LogEvent" must { + "not cause StackOverflowError" in { + implicit val s = ActorSystem("foo", ticket3165Config) + try { + SerializationExtension(s).serialize(Warning("foo", classOf[String])) + } finally { + s.shutdown() + s.awaitTermination(5.seconds.dilated) + } + } + } } diff --git a/akka-actor/src/main/scala/akka/event/Logging.scala b/akka-actor/src/main/scala/akka/event/Logging.scala index 266958bf83..dc35609dee 100644 --- a/akka-actor/src/main/scala/akka/event/Logging.scala +++ b/akka-actor/src/main/scala/akka/event/Logging.scala @@ -570,7 +570,7 @@ object Logging { /** * Base type of LogEvents */ - sealed trait LogEvent { + sealed trait LogEvent extends NoSerializationVerificationNeeded { /** * The thread that created this log event */