Skip to content

Commit

Permalink
PP-11725 upgrade Dropwizard to version 3
Browse files Browse the repository at this point in the history
- Upgrade Dropwizard to v3 latest.

- Use dropwizard-dependencies BOM, which removes the need to pull in some dependencies ourselves
  • Loading branch information
SandorArpa committed Feb 16, 2024
1 parent df29b87 commit 6bc0dc1
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ updates:
- dependency-name: "eclipse-temurin"
versions:
- "> 11"
- dependency-name: "io.dropwizard:dropwizard-dependencies"
# Dropwizard 4.x only works with Jakarta EE and not Java EE
versions:
- ">= 4"
- dependency-name: "org.dhatim:dropwizard-sentry"
# We essentially forked Dropwizard Sentry because it did not support
# Dropwizard 3.x — there is now a Dropwizard Sentry 4.x, which supports
# Dropwizard 4.x (and maybe Dropwizard 3.x), but we’d need to do work
# to go back to using an unmodified version
versions:
- ">= 4"
open-pull-requests-limit: 10
labels:
- dependencies
Expand Down
102 changes: 50 additions & 52 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dropwizard.version>2.1.12</dropwizard.version>
<hamcrest.version>2.2</hamcrest.version>
<jmh.version>1.37</jmh.version>
<jackson.version>2.16.1</jackson.version>
<mockito.version>5.10.0</mockito.version>
<pay-java-commons.version>1.0.20240205110547</pay-java-commons.version>
<prometheus.version>0.16.0</prometheus.version>
<surefire.version>3.2.5</surefire.version>
Expand All @@ -23,13 +20,43 @@
<PACT_CONSUMER_TAG/>
</properties>

<parent>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-dependencies</artifactId>
<version>2.1.12</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-dependencies</artifactId>
<version>3.0.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- Main dependencies that are imported from one of the BOMs specified
in <dependencyManagement> so no explicit versions needed -->
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-json-logging</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<!-- Main dependencies that need explicit versions -->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
Expand All @@ -47,46 +74,35 @@
</dependency>
<dependency>
<groupId>uk.gov.service.payments</groupId>
<artifactId>logging</artifactId>
<artifactId>logging-dropwizard-3</artifactId>
<version>${pay-java-commons.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.service.payments</groupId>
<artifactId>utils</artifactId>
<version>${pay-java-commons.version}</version>
</dependency>

<!-- Test dependencies that are imported from one of the BOMs specified
in <dependencyManagement> so no explicit versions needed -->

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
<artifactId>dropwizard-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.dhatim</groupId>
<artifactId>dropwizard-sentry</artifactId>
<version>2.1.2-4</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-json-logging</artifactId>
<version>${dropwizard.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<!-- testing -->
<!-- Test dependencies that need explicit versions -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand All @@ -99,18 +115,6 @@
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<version>${dropwizard.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down Expand Up @@ -140,16 +144,10 @@
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit5</artifactId>
<version>4.5.6</version>
<version>4.5.8</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/uk/gov/pay/card/app/CardApi.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package uk.gov.pay.card.app;

import com.codahale.metrics.health.HealthCheck;
import io.dropwizard.Application;
import io.dropwizard.configuration.EnvironmentVariableSubstitutor;
import io.dropwizard.configuration.SubstitutingSourceProvider;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.Application;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.dropwizard.DropwizardExports;
import io.prometheus.client.exporter.MetricsServlet;
Expand All @@ -21,6 +21,7 @@
import uk.gov.service.payments.logging.GovUkPayDropwizardRequestJsonLogLayoutFactory;
import uk.gov.service.payments.logging.LoggingFilter;
import uk.gov.service.payments.logging.LogstashConsoleAppenderFactory;
import uk.gov.service.payments.logging.SentryAppenderFactory;

import java.util.List;

Expand Down Expand Up @@ -48,6 +49,7 @@ public void initialize(Bootstrap<CardConfiguration> bootstrap) {
);

bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(LogstashConsoleAppenderFactory.class);
bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(SentryAppenderFactory.class);
bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(GovUkPayDropwizardRequestJsonLogLayoutFactory.class);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.pay.card.app.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;

import javax.validation.constraints.NotNull;
import java.net.URI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.codahale.metrics.health.HealthCheck;
import com.google.common.collect.ImmutableMap;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.setup.Environment;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ logging:
customFields:
container: "cardid"
environment: ${ENVIRONMENT}
- type: sentry
- type: pay-dropwizard-3-sentry
threshold: ERROR
dsn: ${SENTRY_DSN:-https://example.com@dummy/1}
environment: ${ENVIRONMENT}
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/uk/gov/pay/card/pact/ConnectorContractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth;
import au.com.dius.pact.provider.junitsupport.loader.PactFolder;
import au.com.dius.pact.provider.junitsupport.loader.VersionSelector;
import au.com.dius.pact.provider.junitsupport.target.Target;
import au.com.dius.pact.provider.junitsupport.target.TestTarget;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.jayway.jsonassert.JsonAssert;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.setup.Environment;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down

0 comments on commit 6bc0dc1

Please sign in to comment.