Search code examples
scalaplayframeworkredisplayframework-2.0play-json

getting a warn from play application when using OFormat to serialize case class


I have a func where I use a play-json OFormat to serialize case class for api response, and now I notice some warn I get in the logs of the play app that looks like this:

zation(akka://application)(77) - Using the default Java serializer for class [model.ValidationResponse] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage'

does anyone had it before? personally never seen this before..

like in any of my apps I use play-json and my serializer is just:

object CustomSerializer {
  implicit val ValidationResponseFormat: OFormat[ValidationResponse] = Json.format[ValidationResponse]
}

and then I import it where ever I need it.

would love to hear if someone had it before and what should I do in this case.

never seen it before, but what changed recently in this func is that I added cache (play-redis), maybe it has something to do with that?


Solution

  • The reason for the warning is the message serialization between Akka actors. It is not your "play-json and my serializer is just:".

    You started to use play-redis and the plugin use Akka actors, and use the simplest serialization, the java serialization. It is slow so they recommend do not use it in the productions (that's why the warning exist), you need to change it in the settings.

    https://github.com/KarelCemus/play-redis enter image description here

    The more about Akka serialization settings and this warning you can find in the answers to this question: akka-remote serializable warning