Skip to content

Upgrade to Jackson 3#934

Merged
dennisvang merged 2 commits into
maintenance/920-upgrade-to-spring-boot-4from
maintenance/933-upgrade-to-jackson-3
Jun 22, 2026
Merged

Upgrade to Jackson 3#934
dennisvang merged 2 commits into
maintenance/920-upgrade-to-spring-boot-4from
maintenance/933-upgrade-to-jackson-3

Conversation

@dennisvang

@dennisvang dennisvang commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
  • replaced ObjectMapper by JsonMapper with new builder api
  • fixed corresponding imports:
    com.fasterxml.jackson moved to tools.jackson except for com.fasterxml.jackson.annotation
  • replaced JsonProcessingException by JacksonException
  • replaced MappingJackson2HttpMessageConverter by JacksonJsonHttpMessageConverter (actually a spring thing but the former is deprecated and does not accept JsonMapper)

fixes #933

@dennisvang dennisvang added the chore Maintenance label Jun 19, 2026
@dennisvang
dennisvang force-pushed the maintenance/933-upgrade-to-jackson-3 branch from f96ad3a to 99fce99 Compare June 22, 2026 10:55
this fixes the following error:
"Cannot map null into type boolean (set DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)"
- fix corresponding imports: com.fasterxml.jackson moved to tools.jackson except for com.fasterxml.jackson.annotation
- replace JsonProcessingException by JacksonException
- replace MappingJackson2HttpMessageConverter by JacksonJsonHttpMessageConverter
@dennisvang
dennisvang force-pushed the maintenance/933-upgrade-to-jackson-3 branch from 99fce99 to f5b15b0 Compare June 22, 2026 17:20
@dennisvang
dennisvang marked this pull request as ready for review June 22, 2026 17:50
@dennisvang
dennisvang merged commit 93e6a36 into maintenance/920-upgrade-to-spring-boot-4 Jun 22, 2026
13 checks passed
@dennisvang
dennisvang deleted the maintenance/933-upgrade-to-jackson-3 branch June 22, 2026 17:53
This was referenced Jun 22, 2026
dennisvang added a commit that referenced this pull request Jun 26, 2026
* bump spring-boot-starter-parent from 3.5.14 to 4.1.0 (latest)

* Upgrade to Jackson 3 (#934)

* upgrade fairdatateam packages:
  - bump spring-security-acl-mongodb version from 6.0.4 to 6.0.5
  - bump rdf-resource-resolver version from 0.2.0 to 0.2.2
  - bump spring-rdf-migration version from 2.0.0 to 2.0.1

* replace spring.data.mongodb by spring.mongodb in application.yml

  see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Configuration-Changelog

* rename spring-boot-starter-aop to spring-boot-starter-aspectj

  see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#aop-starter-pom

* replace deprecated spring-boot-starter-web by spring-boot-starter-webmvc and replace spring-boot-starter-test by spring-boot-starter-webmvc-test (which brings in spring-boot-starter-test as transitive dependency)

  https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#deprecated-starters
  https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#test-code

* remove android-json exclusion from spring-boot-starter-test, as it does not appear to do anything

* replace spring-security-test by spring-boot-starter-security-test, as mentioned in https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#test-code

* remove redundant spring-data-mongodb dependency, because this is already pulled in by spring-boot-starter-data-mongodb (via spring-boot-starter-mongodb)

  https://central.sonatype.com/artifact/org.springframework.boot/spring-boot-starter-data-mongodb/4.0.6
  https://central.sonatype.com/artifact/org.springframework.boot/spring-boot-data-mongodb/4.0.6

* replace deprecated PersistenceConstructor by PersistenceCreator (cannot find this in spring-data-commons release notes, but see e.g. spring-projects/spring-data-neo4j@1c11be9)

* add spring-boot-starter-restclient and corresponding test starter, fix corresponding RestTemplateBuilder import, and replace deprecated setConnectionTimeout and setReadTimeout calls

  https://docs.spring.io/spring-boot/3.4/api/java/org/springframework/boot/web/client/RestTemplateBuilder.html

* fix imports for AutoConfigureMockMvc and AutoConfigureMockRestServiceServer, because these have been moved from org.springframework.boot.test.autoconfigure.web to two different packages

* add spring-boot-starter-micrometer-metrics dependency and fix corresponding metrics imports (see spring-projects/spring-boot#50788)

* revert spring-boot-starter-micrometer-metrics dependency because spring-boot-starter-actuator already pulls that in (see https://github.com/spring-projects/spring-boot/blob/2edca39504f8e9c2943262d3e60ba34b0e7751ac/starter/spring-boot-starter-actuator/build.gradle#L25)

* remove unused setFromHttpEntity method, because, not only is it unused, but it gives rise to the following error in spring-boot 4: "incompatible types: org.springframework.http.HttpHeaders cannot be converted to java.util.Map<java.lang.String,java.util.List<java.lang.String>>"

* fix TestRestTemplate imports (class has been moved to org.springframework.boot.resttestclient package in spring-boot 4)

* replace ClientHttpRequestFactorySettings.Redirects by HttpRedirects because org.springframework.boot.http.client.ClientHttpRequestFactorySettings has been removed, apparently

* fix HttpHeaders assertions because the class no longer extends MultiValueMap

* rearrange httpclient5 dependency (this was listed under 'Test' dependencies, but does not specify the test scope)

* explicit dependency on jakarta.servlet-api

  This is available via spring-boot starters (jetty?), but we depend heavily on this package and import explicitly from it, so better make the dependency explicit. The package version is managed by spring boot.
https://docs.spring.io/spring-boot/appendix/dependency-versions/coordinates.html

* bump springdoc-openapi-starter-webmvc-ui from 2.8.16 to 3.0.3, for compatibility with spring-boot 4 (spring 7)

* add @AutoConfigureTestRestTemplate to WebIntegrationTest because @SpringBootTest no longer provides the TestRestTemplate bean, as mentioned in the migration guide:
  https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#using-webclient-or-testresttemplate-and-springboottest

* make setup() public in HarvesterServiceTest

* clean up spring-boot-starters, following the spring-boot-starter-classic workflow described in the spring boot 4 migration guide

* explicit jackson dependency: we import directly from the jackson packages in many places, so the dependency should be explicit instead of only transitive

* explicit dependency on spring-boot-data-mongodb

* use jspecify @nullable in AbstractMetadataRepository (this is the only use of @nullable in the fdp)

* handle null in ResourceDefinitionTargetClassesCache to get rid of the nullpointerexceptions in tests, like:

  "Cannot invoke org.fairdatateam.fairdatapoint.entity.schema.MetadataSchema.getTargetClasses()
    because the return value of java.util.Map.get(Object) is null at org.fairdatateam.fairdatapoint.service.resource.ResourceDefinitionTargetClassesCache.lambda$computeCache$2(ResourceDefinitionTargetClassesCache.java:84)"

* fix style for ResourceDefinitionTargetClassesCache

* configure mongodb uuid representation 

  an alternative would be something like:

  ```java
  @configuration
  public class MongoClientConfig extends AbstractMongoClientConfiguration {

      @value("${spring.mongodb.database}")
      private String databaseName;

      @OverRide
      protected void configureClientSettings(MongoClientSettings.Builder builder) {
          builder.uuidRepresentation(UuidRepresentation.STANDARD);
      }

      @OverRide
      protected @nonnull String getDatabaseName() {
          return databaseName;
      }
  }
  ```

  https://docs.spring.io/spring-data/mongodb/reference/migration-guide/migration-guide-4.x-to-5.x.html

* explicit no-args constructor for MetadataSchemaDraftDTO marked as @JsonCreator (fixes the "Cannot map `null` into type `boolean`" error)

  also see FasterXML/jackson-databind#5318 and https://github.com/FasterXML/jackson/wiki/Jackson-Release-3.0#jackson-databind

* change MetadataSchemaDraftDTO.abstractSchema boolean to Boolean

  this fixes the following error: "Cannot map null into type boolean (set DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)"

* replace ObjectMapper by JsonMapper with new builder api

    - fix corresponding imports: com.fasterxml.jackson moved to tools.jackson except for com.fasterxml.jackson.annotation
    - replace JsonProcessingException by JacksonException
    - replace MappingJackson2HttpMessageConverter by JacksonJsonHttpMessageConverter

* switch WebMvcConfig to constructor autowiring, while we're at it

* update configureMessageConverters to use ServerBuilder because the original method is deprecated for removal

* annotate ContentNegotiationConfigurer NonNull to match parent signature

* explicit dependency on slf4j, because it is used explicitly throughout the code, but was only included transitively (implicitly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant