Commit af2cb20
authored
FM-496 - Upgrade to Spring Boot 4 (#4699)
## Summary
This PR upgrades the API to spring boot 4. An 'non squashed' version of
the PR is available for reference
[here](#4666)
## Upgrade build.gradle for spring boot 4
## Update jdbctemplate usage to reflect null response
## Use updated arguments for ContentCachingFilter
## Update Redis Config Namespace
## Add missing caching request wrapper to filter
## Force nullability on implementation of ConverterFactory
Annotations like @nullable on a Java generic bound do not propagate into
Kotlin’s type system for type parameters. Because the Converter
interface has been updated to use this construct Kotlin can no longer
infer nullabliity
```
public interface Converter<S, T extends @nullable Object> {
T convert(S source);
}
```
## Use latest health interface
## Update common paging code for new interfaces
## replace SpykBean with MockkSpykBean
This is required for mockk upgrade, see
https://github.com/Ninja-Squad/springmockk/blob/master/README.md#migrating-to-version-5x
## Block first can now return null values
## queryParam is now nullable
## connection pool imports have changed
## Fix exception handling test exceptions
## Fix use of jsonPath.value
## Junit callbacks are no longer nullable
## ApplicationContextInitializer is no longer nullable
## Repository.save can no longer return null
## Fix exception handling unit
## Fix IT data source configuration
## Update spring jackson configuration
This also removes the `serialization` configuration for jackson 3
because it is no longer supported
the `spring.jackson` configuration now applies to jackson3, not
jackson2.
`SerializationFeature.WRITE_DATES_AS_TIMESTAMPS now known as
DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS has been changed to false to
serialize dates as ISO-8601 strings.`
for this reason, we remove the `WRITE_DATES_AS_TIMESTAMPS` config for
jackson 3
Jackson 2 configuration has been added as `spring.jackson2`, matching
the pre spring-boot-4 upgrade configuration.
## Explicitly add and configure webtestclient
## Ensure JPA Attributes are serializable
The JPA specification requires that the entity attributes are
Serializable`
## Remove unused dependencies
## Handle Jackson3 Exception Handling
Before the spring boot 4 upgrade Jackson 2 was used by Spring MVC,
meaning our exception handling responding to unmarshalling issues deal
with Jackson 2 classes.
Spring Boot 4 uses jackson 3 for Spring MVC. This commit updates
exception handling to work solely using Jackson3 for exception handling.
It also simplifies how we use Spring’s `ProblemDetail` type, which is
now correctly placing properties at the top level of the returned JSON
instead of in a ‘properties’ attribute. This is mostly likely due to the
upgrade to Jackson 3. This allows us to simplify the expected problem
JSON in our integration tests, making the JSON match the returned values
we saw from Zalando Problem before moving to Spring Problem
## Method Argument Mismatch now produces a problem
Before upgrading to spring boot 4 `MethodArgumentTypeMismatchException`
would return a generic error. It now returns a JSON Problem, which is
preferred.
## Use Jackson 3 for API `Any` types
As of Spring Boot 4 API marshalling is handled by Jackson 3.
In many places JSON ‘blobs’ are represented in our API model with an
‘Any’ type:
For example, in `ApprovedPremisesApplication` we have
`val document: Any? = null,`
This is populated as follows:
1. Pull JSON from the database as a String
2. Use Jackson to unmarshall this is into an internal Jackson Type
3. Set this value on the `Any` property
4. Spring Web MVC marshalls the `Any` value into JSON in the response
This works fine when the version of Jacksonused in step 2 and 4 are the
same. But if Step 2 uses Jackson2 and Step 4 uses Jackson3 (which is the
configuration we have after upgrading to Spring 4), Jackson3 doesn’t
recognise the Jackson2 native value in the `Any` property and falls back
to default serialization, resulting in something like the following:
`{"array":false,"bigDecimal":false,"bigInteger":false,"binary":false,"boolean":false,"containerNode":true,"double":false,"empty":true,"float":false,"floatingPointNumber":false,"int":false,"integralNumber":false,"long":false,"missingNode":false,"nodeType":"OBJECT","null":false,"number":false,"object":true,"pojo":false,"short":false,"textual":false,"valueNode":false}
`
For this reason we’ve upgraded all places that use Jackson to populate
the `Any` value to use Jackson 3.
Other uses of Jackson will upgraded in subsequent commits
## Migrate some benign jackson2 usage to jackson3
## Pin openapi starter version working version
springdoc/springdoc-openapi#3256 significantly
changed our generated schema, making it incompatible with the typescript
generators and in some places it was incorrect. We're pinning version
3.0.2 until a new version is available reverting this change, as
proposed by springdoc/springdoc-openapi#3276104 files changed
Lines changed: 396 additions & 493 deletions
File tree
- src
- main
- kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi
- cas1
- migration
- seed
- cas2v2
- controller
- service
- transformer
- cas2
- controller
- service
- transformer
- cas3
- controller
- migration
- service
- transformer
- config
- controller
- cas1
- convert
- health
- jpa/entity
- model
- problem
- service
- cas1
- subjectaccessrequests
- transformer
- cas1
- util
- resources
- test/kotlin/uk/gov/justice/digital/hmpps/approvedpremisesapi
- cas1/unit/seed
- cas2v2
- integration
- unit
- service
- transformer
- cas2
- integration
- migration
- unit
- service
- transformer
- cas3
- integration
- migration
- unit
- service
- transformer
- health
- integration
- cas1
- config
- unit
- problem
- service
- cas1
- transformer
- cas1
- util
- util
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
46 | | - | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
69 | | - | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
77 | 79 | | |
78 | | - | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments