Skip to content

Commit

Permalink
attempt to use Jackson.newObjectMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Apr 17, 2023
1 parent 140ecb7 commit 87333e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 4 additions & 0 deletions legend-sdlc-server-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.prometheus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions legend-sdlc-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 87333e4

Please sign in to comment.