Skip to content

Commit 7accd18

Browse files
authored
Merge pull request #162 from companieshouse/feature/JU-89-java-21-migration
Feature/ju 89 java 21 migration
2 parents 851d26f + ffa8ac8 commit 7accd18

File tree

72 files changed

+1124
-457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1124
-457
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ sonar:
6767
sonar-pr-analysis:
6868
mvn sonar:sonar -P sonar-pr-analysis
6969

70+
.PHONY: security-check
71+
security-check:
72+
mvn org.owasp:dependency-check-maven:update-only
73+
mvn org.owasp:dependency-check-maven:check -DfailBuildOnCVSS=4 -DassemblyAnalyzerEnabled=false

ecs-image-build/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM 416670754337.dkr.ecr.eu-west-2.amazonaws.com/ci-corretto-runtime-21:latest
2+
3+
WORKDIR /opt
4+
COPY /app .
5+
COPY docker_start.sh .
6+
7+
CMD ["./docker_start.sh"]

ecs-image-build/docker_start.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
#
3+
# Start script for orders.api.ch.gov.uk
4+
5+
PORT=8080
6+
7+
exec java -jar -Dserver.port="${PORT}" "orders.api.ch.gov.uk.jar"

ecs-image-build/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ecs-1.0

pom.xml

Lines changed: 138 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<parent>
77
<groupId>uk.gov.companieshouse</groupId>
88
<artifactId>companies-house-parent</artifactId>
9-
<version>1.3.0</version>
9+
<version>2.1.5</version>
1010
</parent>
1111
<artifactId>orders.api.ch.gov.uk</artifactId>
1212
<version>unversioned</version>
1313
<name>orders.api.ch.gov.uk</name>
1414
<description>CH API handling CRUD operations on Ordering Service</description>
1515

1616
<properties>
17-
<kafka-models.version>1.0.26</kafka-models.version>
18-
<ch-kafka.version>1.4.2</ch-kafka.version>
19-
<java.version>1.8</java.version>
20-
<structured-logging.version>1.9.12</structured-logging.version>
21-
<commons.lang.version>2.6</commons.lang.version>
17+
<maven.compiler.release>21</maven.compiler.release>
18+
<ch-kafka.version>3.0.1</ch-kafka.version>
19+
<kafka-models.version>3.0.7</kafka-models.version>
20+
<java.version>21</java.version>
21+
<structured-logging.version>3.0.3</structured-logging.version>
22+
<commons.lang.version>3.14.0</commons.lang.version>
2223
<commons.beanutils.version>1.9.4</commons.beanutils.version>
23-
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
24-
<gson.version>2.8.0</gson.version>
25-
<hamcrest-all-version>1.3</hamcrest-all-version>
24+
<org.mapstruct.version>1.5.5.FINAL</org.mapstruct.version>
25+
<gson.version>2.10.1</gson.version>
26+
<hamcrest.version>2.2</hamcrest.version>
2627
<!-- system-rules: 1.17.2 is the latest version that works with JUnit 5.
2728
See https://github.com/stefanbirkner/system-rules/issues/70 -->
2829
<system-rules-version>1.17.2</system-rules-version>
29-
<spring-cloud-contract-wiremock-version>2.2.2.RELEASE</spring-cloud-contract-wiremock-version>
30+
<spring-cloud-contract-wiremock-version>4.1.1</spring-cloud-contract-wiremock-version>
3031
<start-class>uk.gov.companieshouse.orders.api.OrdersApiApplication</start-class>
31-
<private-api-sdk-java.version>2.0.286</private-api-sdk-java.version>
32-
<api-sdk-manager-java-library.version>1.0.3</api-sdk-manager-java-library.version>
33-
<api-sdk-java.version>4.3.3</api-sdk-java.version>
34-
<api-helper-java.version>1.4.1</api-helper-java.version>
35-
<api-security-java.version>0.3.4</api-security-java.version>
36-
37-
<spring-boot-dependencies.version>2.5.5</spring-boot-dependencies.version>
38-
<spring-boot-maven-plugin.version>2.5.5</spring-boot-maven-plugin.version>
39-
40-
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
41-
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
42-
43-
<log4j-version>2.17.1</log4j-version>
44-
32+
<private-api-sdk-java.version>4.0.76</private-api-sdk-java.version>
33+
<api-sdk-manager-java-library.version>3.0.5</api-sdk-manager-java-library.version>
34+
<api-sdk-java.version>6.0.9</api-sdk-java.version>
35+
<api-helper-java.version>3.0.1</api-helper-java.version>
36+
<api-security-java.version>2.0.0</api-security-java.version>
37+
<de-flapdoodle-embed-mongo.version>4.9.3</de-flapdoodle-embed-mongo.version>
38+
<wiremock-standalone.version>3.4.2</wiremock-standalone.version>
39+
<spring-boot-dependencies.version>3.2.4</spring-boot-dependencies.version>
40+
<spring-boot-maven-plugin.version>3.2.0</spring-boot-maven-plugin.version>
41+
<commons-compress.version>1.26.1</commons-compress.version>
42+
<maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
43+
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
44+
<log4j-version>2.20.0</log4j-version>
45+
<http2-common.version>11.0.20</http2-common.version>
46+
<test-containers.version>1.19.7</test-containers.version>
4547
<!-- Docker -->
46-
<jib-maven-plugin.version>3.1.1</jib-maven-plugin.version>
48+
<jib-maven-plugin.version>3.4.1</jib-maven-plugin.version>
4749
</properties>
4850

4951
<dependencyManagement>
@@ -59,6 +61,45 @@
5961
</dependencyManagement>
6062

6163
<dependencies>
64+
<dependency>
65+
<groupId>org.testcontainers</groupId>
66+
<artifactId>testcontainers-bom</artifactId>
67+
<version>${test-containers.version}</version>
68+
<type>pom</type>
69+
<scope>import</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-starter-actuator</artifactId>
74+
<version>3.2.4</version>
75+
</dependency>
76+
<dependency>
77+
<!--Overriding spring-web version to remove vulnerability-->
78+
<groupId>org.springframework</groupId>
79+
<artifactId>spring-web</artifactId>
80+
<version>6.1.6</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.apache.commons</groupId>
84+
<artifactId>commons-compress</artifactId>
85+
<version>${commons-compress.version}</version>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.eclipse.jetty.http2</groupId>
89+
<artifactId>http2-common</artifactId>
90+
<version>${http2-common.version}</version>
91+
</dependency>
92+
<dependency>
93+
<groupId>jakarta.servlet</groupId>
94+
<artifactId>jakarta.servlet-api</artifactId>
95+
<version>6.0.0</version>
96+
<scope>provided</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>jakarta.validation</groupId>
100+
<artifactId>jakarta.validation-api</artifactId>
101+
<version>3.0.2</version>
102+
</dependency>
62103
<dependency>
63104
<groupId>org.springframework.boot</groupId>
64105
<artifactId>spring-boot-starter-validation</artifactId>
@@ -70,6 +111,26 @@
70111
<dependency>
71112
<groupId>org.springframework.boot</groupId>
72113
<artifactId>spring-boot-starter-web</artifactId>
114+
<exclusions>
115+
<exclusion>
116+
<groupId>org.springframework.boot</groupId>
117+
<artifactId>spring-boot-starter-logging</artifactId>
118+
</exclusion>
119+
<exclusion>
120+
<groupId>org.apache.logging.log4j</groupId>
121+
<artifactId>log4j-to-slf4j</artifactId>
122+
</exclusion>
123+
</exclusions>
124+
</dependency>
125+
<dependency>
126+
<groupId>org.springframework.boot</groupId>
127+
<artifactId>spring-boot-starter</artifactId>
128+
<exclusions>
129+
<exclusion>
130+
<groupId>org.springframework.boot</groupId>
131+
<artifactId>spring-boot-starter-logging</artifactId>
132+
</exclusion>
133+
</exclusions>
73134
</dependency>
74135
<dependency>
75136
<groupId>uk.gov.companieshouse</groupId>
@@ -89,12 +150,23 @@
89150
<dependency>
90151
<groupId>org.springframework.boot</groupId>
91152
<artifactId>spring-boot-starter-data-mongodb</artifactId>
153+
<exclusions>
154+
<exclusion>
155+
<groupId>org.springframework.boot</groupId>
156+
<artifactId>spring-boot-starter-logging</artifactId>
157+
</exclusion>
158+
</exclusions>
92159
</dependency>
93160
<dependency>
94161
<groupId>org.springframework.boot</groupId>
95162
<artifactId>spring-boot-starter-aop</artifactId>
163+
<exclusions>
164+
<exclusion>
165+
<groupId>org.springframework.boot</groupId>
166+
<artifactId>spring-boot-starter-logging</artifactId>
167+
</exclusion>
168+
</exclusions>
96169
</dependency>
97-
98170
<dependency>
99171
<groupId>org.springframework.boot</groupId>
100172
<artifactId>spring-boot-starter-test</artifactId>
@@ -106,48 +178,59 @@
106178
</exclusion>
107179
</exclusions>
108180
</dependency>
109-
110181
<dependency>
111182
<groupId>uk.gov.companieshouse</groupId>
112183
<artifactId>structured-logging</artifactId>
113184
<version>${structured-logging.version}</version>
114185
<scope>compile</scope>
186+
<exclusions>
187+
<exclusion>
188+
<groupId>org.slf4j</groupId>
189+
<artifactId>slf4j-simple</artifactId>
190+
</exclusion>
191+
</exclusions>
115192
</dependency>
193+
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
116194
<dependency>
117-
<groupId>commons-lang</groupId>
118-
<artifactId>commons-lang</artifactId>
195+
<groupId>org.apache.commons</groupId>
196+
<artifactId>commons-lang3</artifactId>
119197
<version>${commons.lang.version}</version>
120198
</dependency>
121199
<dependency>
122200
<groupId>commons-beanutils</groupId>
123201
<artifactId>commons-beanutils</artifactId>
124202
<version>${commons.beanutils.version}</version>
125203
</dependency>
126-
127204
<dependency>
128205
<groupId>uk.gov.companieshouse</groupId>
129-
<artifactId>kafka-models</artifactId>
130-
<version>${kafka-models.version}</version>
206+
<artifactId>ch-kafka</artifactId>
207+
<version>${ch-kafka.version}</version>
131208
</dependency>
132209
<dependency>
133210
<groupId>uk.gov.companieshouse</groupId>
134-
<artifactId>ch-kafka</artifactId>
135-
<version>${ch-kafka.version}</version>
211+
<artifactId>kafka-models</artifactId>
212+
<version>${kafka-models.version}</version>
136213
</dependency>
137214
<dependency>
138215
<groupId>org.hibernate.validator</groupId>
139216
<artifactId>hibernate-validator</artifactId>
140217
</dependency>
141-
142218
<dependency>
143219
<groupId>org.springframework.kafka</groupId>
144220
<artifactId>spring-kafka-test</artifactId>
145221
<scope>test</scope>
222+
<version>3.0.13</version>
223+
<exclusions>
224+
<exclusion>
225+
<groupId>org.pcollections</groupId>
226+
<artifactId>pcollections</artifactId>
227+
</exclusion>
228+
</exclusions>
146229
</dependency>
147230
<dependency>
148231
<groupId>org.hamcrest</groupId>
149-
<artifactId>hamcrest-all</artifactId>
150-
<version>${hamcrest-all-version}</version>
232+
<artifactId>hamcrest</artifactId>
233+
<version>${hamcrest.version}</version>
151234
<scope>test</scope>
152235
</dependency>
153236
<dependency>
@@ -178,8 +261,13 @@
178261
<version>${api-sdk-manager-java-library.version}</version>
179262
</dependency>
180263
<dependency>
181-
<groupId>de.flapdoodle.embed</groupId>
182-
<artifactId>de.flapdoodle.embed.mongo</artifactId>
264+
<groupId>org.testcontainers</groupId>
265+
<artifactId>mongodb</artifactId>
266+
<scope>test</scope>
267+
</dependency>
268+
<dependency>
269+
<groupId>org.testcontainers</groupId>
270+
<artifactId>junit-jupiter</artifactId>
183271
<scope>test</scope>
184272
</dependency>
185273
<dependency>
@@ -204,11 +292,6 @@
204292
<artifactId>log4j-api</artifactId>
205293
<version>${log4j-version}</version>
206294
</dependency>
207-
<dependency>
208-
<groupId>org.apache.logging.log4j</groupId>
209-
<artifactId>log4j-to-slf4j</artifactId>
210-
<version>${log4j-version}</version>
211-
</dependency>
212295
</dependencies>
213296

214297
<build>
@@ -261,6 +344,9 @@
261344
<groupId>org.apache.maven.plugins</groupId>
262345
<artifactId>maven-surefire-plugin</artifactId>
263346
<version>${maven-surefire-plugin.version}</version>
347+
<configuration>
348+
<argLine>--add-opens=java.base/java.util=ALL-UNNAMED</argLine>
349+
</configuration>
264350
</plugin>
265351
<plugin>
266352
<groupId>com.google.cloud.tools</groupId>
@@ -270,6 +356,12 @@
270356
<container>
271357
<expandClasspathDependencies>true</expandClasspathDependencies>
272358
</container>
359+
<from>
360+
<image>416670754337.dkr.ecr.eu-west-2.amazonaws.com/ci-corretto-build-21:latest</image>
361+
</from>
362+
<to>//Once the pipeline is moved to shared services need to update this to image reference from shared services
363+
<image>169942020521.dkr.ecr.eu-west-1.amazonaws.com/local/orders.api.ch.gov.uk:latest</image>
364+
</to>
273365
</configuration>
274366
</plugin>
275367
</plugins>

src/main/java/uk/gov/companieshouse/orders/api/config/ApplicationConfig.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static uk.gov.companieshouse.orders.api.controller.BasketController.APPEND_ITEM_URI;
44
import static uk.gov.companieshouse.orders.api.controller.BasketController.PATCH_PAYMENT_DETAILS_URI;
5-
import static uk.gov.companieshouse.orders.api.controller.HealthcheckController.HEALTHCHECK_URI;
65
import static uk.gov.companieshouse.orders.api.controller.OrderController.CHECKOUTS_SEARCH_URI;
76

87
import org.springframework.beans.factory.annotation.Value;
@@ -34,7 +33,6 @@ public class ApplicationConfig implements WebMvcConfigurer {
3433
private final UserAuthorisationInterceptor authorisationInterceptor;
3534
private final OrdersSearchEndpointFeatureToggle ordersSearchEndpointFeatureToggle;
3635
private final BasketEnrollmentFeatureToggle basketEnrollmentFeatureToggle;
37-
private final String healthcheckUri;
3836
private final String paymentDetailsUri;
3937
private final String ordersSearchUri;
4038
private final String appendItemUri;
@@ -44,7 +42,6 @@ public ApplicationConfig(final LoggingInterceptor loggingInterceptor,
4442
final UserAuthorisationInterceptor authorisationInterceptor,
4543
final OrdersSearchEndpointFeatureToggle ordersSearchEndpointFeatureToggle,
4644
final BasketEnrollmentFeatureToggle basketEnrollmentFeatureToggle,
47-
@Value(HEALTHCHECK_URI) final String healthcheckUri,
4845
@Value(PATCH_PAYMENT_DETAILS_URI) final String paymentDetailsUri,
4946
@Value(CHECKOUTS_SEARCH_URI) final String ordersSearchUri,
5047
@Value(APPEND_ITEM_URI) final String appendItemUri) {
@@ -53,7 +50,6 @@ public ApplicationConfig(final LoggingInterceptor loggingInterceptor,
5350
this.authorisationInterceptor = authorisationInterceptor;
5451
this.ordersSearchEndpointFeatureToggle = ordersSearchEndpointFeatureToggle;
5552
this.basketEnrollmentFeatureToggle = basketEnrollmentFeatureToggle;
56-
this.healthcheckUri = healthcheckUri;
5753
this.paymentDetailsUri = paymentDetailsUri;
5854
this.ordersSearchUri = ordersSearchUri;
5955
this.appendItemUri = appendItemUri;
@@ -64,9 +60,9 @@ public void addInterceptors(final InterceptorRegistry registry) {
6460
registry.addInterceptor(loggingInterceptor);
6561
registry.addInterceptor(basketEnrollmentFeatureToggle).addPathPatterns(appendItemUri);
6662
registry.addInterceptor(ordersSearchEndpointFeatureToggle).addPathPatterns(ordersSearchUri);
67-
registry.addInterceptor(authenticationInterceptor).excludePathPatterns(healthcheckUri);
68-
registry.addInterceptor(authorisationInterceptor).excludePathPatterns(healthcheckUri);
69-
registry.addInterceptor(crudPermissionInterceptor()).excludePathPatterns(paymentDetailsUri, healthcheckUri);
63+
registry.addInterceptor(authenticationInterceptor);
64+
registry.addInterceptor(authorisationInterceptor);
65+
registry.addInterceptor(crudPermissionInterceptor()).excludePathPatterns(paymentDetailsUri);
7066
// Different interceptor for payment details as API key traffic needs to be allowed:
7167
// - PATCH is always ignored since oauth2 is blocked for this function
7268
// - GET ignores API key requests to allow payments api to get costs but if oauth2 is used it still checks token permissions

0 commit comments

Comments
 (0)