From 87333e42b49c6f75b13ef59e95c2c525dd3a2b3f Mon Sep 17 00:00:00 2001 From: An Phi Date: Mon, 17 Apr 2023 13:29:14 -0400 Subject: [PATCH] attempt to use Jackson.newObjectMapper --- legend-sdlc-server-shared/pom.xml | 4 ++++ .../sdlc/server/BaseServerJacksonJsonProvider.java | 10 ++-------- legend-sdlc-server/pom.xml | 4 ++++ .../LegendSDLCServerForTestJacksonJsonProvider.java | 10 ++-------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/legend-sdlc-server-shared/pom.xml b/legend-sdlc-server-shared/pom.xml index c3e6f7b196..1390a0adb3 100644 --- a/legend-sdlc-server-shared/pom.xml +++ b/legend-sdlc-server-shared/pom.xml @@ -98,6 +98,10 @@ io.dropwizard.metrics metrics-healthchecks + + io.dropwizard + dropwizard-jackson + io.prometheus diff --git a/legend-sdlc-server-shared/src/main/java/org/finos/legend/sdlc/server/BaseServerJacksonJsonProvider.java b/legend-sdlc-server-shared/src/main/java/org/finos/legend/sdlc/server/BaseServerJacksonJsonProvider.java index 3a88e7d02d..0728aa4c62 100644 --- a/legend-sdlc-server-shared/src/main/java/org/finos/legend/sdlc/server/BaseServerJacksonJsonProvider.java +++ b/legend-sdlc-server-shared/src/main/java/org/finos/legend/sdlc/server/BaseServerJacksonJsonProvider.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import io.dropwizard.jackson.Jackson; import javax.ws.rs.ext.ContextResolver; @@ -26,15 +27,8 @@ public class BaseServerJacksonJsonProvider extends JacksonJsonProvider implement public BaseServerJacksonJsonProvider() { - this.objectMapper = new ObjectMapper() + this.objectMapper = Jackson.newObjectMapper() .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - // NOTE: this call needs to be called separately and not part of the fluent-style declaration block - // above, else things might go wrong in test, this could be due to the weird interaction between - // gitlab4j-api and our old version of dropwizard and their dependencies and service loader magic, - // that we haven't quite figured out just yet. We should clean this up when we upgrade DropWizard - // See https://github.com/FasterXML/jackson-databind/issues/2983 - // See https://github.com/finos/legend-sdlc/pull/414 - this.objectMapper.findAndRegisterModules(); } @Override diff --git a/legend-sdlc-server/pom.xml b/legend-sdlc-server/pom.xml index d286d30c07..20a97344f8 100644 --- a/legend-sdlc-server/pom.xml +++ b/legend-sdlc-server/pom.xml @@ -227,6 +227,10 @@ io.dropwizard.metrics metrics-healthchecks + + io.dropwizard + dropwizard-jackson + io.swagger diff --git a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTestJacksonJsonProvider.java b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTestJacksonJsonProvider.java index ab10c41189..a0cffa77c6 100644 --- a/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTestJacksonJsonProvider.java +++ b/legend-sdlc-server/src/test/java/org/finos/legend/sdlc/server/LegendSDLCServerForTestJacksonJsonProvider.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import io.dropwizard.jackson.Jackson; import org.finos.legend.sdlc.domain.model.entity.Entity; import org.finos.legend.sdlc.domain.model.project.Project; import org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency; @@ -38,7 +39,7 @@ public class LegendSDLCServerForTestJacksonJsonProvider extends JacksonJsonProvi public LegendSDLCServerForTestJacksonJsonProvider() { - this.objectMapper = new ObjectMapper() + this.objectMapper = Jackson.newObjectMapper() .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .addMixIn(Project.class, InMemoryMixins.Project.class) .addMixIn(Workspace.class, InMemoryMixins.Workspace.class) @@ -48,13 +49,6 @@ public LegendSDLCServerForTestJacksonJsonProvider() .addMixIn(ProjectRevision.class, ProjectRevisionMixin.class) .addMixIn(ProjectDependency.class, ProjectDependencyMixin.class) .addMixIn(VersionId.class, VersionIdMixin.class); - // NOTE: this call needs to be called separately and not part of the fluent-style declaration block - // above, else things might go wrong in test, this could be due to the weird interaction between - // gitlab4j-api and our old version of dropwizard and their dependencies and service loader magic, - // that we haven't quite figured out just yet. We should clean this up when we upgrade DropWizard - // See https://github.com/FasterXML/jackson-databind/issues/2983 - // See https://github.com/finos/legend-sdlc/pull/414 - this.objectMapper.findAndRegisterModules(); } @Override