From 3c4efe218dd8c3f434b2af16d9439052d79d7607 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Fri, 6 Nov 2020 19:05:42 +0100 Subject: [PATCH] Restore Jackson visibility defaults --- .../src/main/scala/play/core/ObjectMapperModule.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala b/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala index ed296854ca4..a77fb61112e 100644 --- a/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala +++ b/core/play-java/src/main/scala/play/core/ObjectMapperModule.scala @@ -5,9 +5,10 @@ package play.core import scala.concurrent.Future - import akka.actor.ActorSystem import akka.serialization.jackson.JacksonObjectMapperProvider +import com.fasterxml.jackson.annotation.JsonAutoDetect +import com.fasterxml.jackson.annotation.PropertyAccessor import com.fasterxml.jackson.databind.ObjectMapper import javax.inject._ import play.api.inject._ @@ -36,7 +37,9 @@ class ObjectMapperProvider @Inject() (lifecycle: ApplicationLifecycle, actorSyst JacksonObjectMapperProvider .get(actorSystem) .getOrCreate(ObjectMapperProvider.BINDING_NAME, Option.empty) + mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PUBLIC_ONLY) Json.setObjectMapper(mapper) + lifecycle.addStopHook { () => Future.successful(Json.setObjectMapper(null)) }