Skip to content

GH-10058: Introduce Jackson 3 in the Gradle build #10158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

anthologia
Copy link
Contributor

Related to: #10058

First part of the Jackson 3 support implementation for issue. I've split this work for easier review and management:

  • This PR (Work 1): Jackson 3 dependency management
  • Work 2: Jackson 3 API implementation
  • Work 3: Migration (e.g., from MappingJackson2MessageConverter to JacksonJsonMessageConverter)
  • Work 4: Deprecation Jackson2 APIs

Does this approach work for you?

Related to: spring-projects#10058

* Add `jackson3Version` variable and BOM import
* Include Jackson 3 dependencies across modules

Signed-off-by: Jooyoung Pyoung <[email protected]>
@artembilan
Copy link
Member

Thank you, @anthologia , for looking into this!
However I think the Work 3 has to be done second. Kinda migrate from deprecated upstream.
The part 2 might be divided because we have a lot of places using Jackson 2.
Another problem: we might need to be sure that upstream Spring projects come with respective new API, like Spring Kafka, Spring AMQP, Spring Data. However this could be a good trigger to check with those dependencies if they are planning already to do that migration to Jackson 3.

@@ -497,6 +500,11 @@ project('spring-integration-core') {
api 'io.projectreactor:reactor-core'
api 'io.micrometer:micrometer-observation'

optionalApi 'tools.jackson.core:jackson-databind'
optionalApi 'tools.jackson.datatype:jackson-datatype-joda'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not familiar with Jackson 3 and how it manages time API, but is Joda still a thing?
From where did you take this dependencies arrangement ?
Why there are no more for time, for example and parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Jackson 3, "parameter names" and "datatypes" modules are now built-in.
JSTEP documentation: https://github.com/FasterXML/jackson-future-ideas/wiki/Jackson3-Changes#maven-modules-jars-java-packages

For Joda, I added it by referencing our Jackson2JsonObjectMapper. I tested it as shown below, and without adding JodaModule, Joda couldn't be supported.

public static class JodaData {
    public String name;
    public org.joda.time.DateTime createdAt;

    public JodaData(String name, DateTime createdAt) {
       this.name = name;
       this.createdAt = createdAt;
    }
}

@Test
@DisplayName("[Jackson3] With JodaModule")
public void testJackson3JodaSerializationWithJodaModule() throws Exception {
    tools.jackson.databind.ObjectMapper mapper = JsonMapper.builder()
          .addModule(new JodaModule())
          .build();

    DateTime jodaDateTime = new DateTime();
    JodaData data = new JodaData("John", jodaDateTime);

    String json = mapper.writeValueAsString(data);
    mapper.readValue(json, JodaData.class);
    System.out.println("✅ Joda works with JodaModule in Jackson 3");
}

@Test
@DisplayName("[Jackson3] Without JodaModule")
public void testJackson3JodaSerializationWithoutJodaModule() throws Exception {
    tools.jackson.databind.ObjectMapper mapper = JsonMapper.builder()
          .build();

    DateTime jodaDateTime = new DateTime();
    JodaData data = new JodaData("John", jodaDateTime);

    Assert.assertThrows(tools.jackson.core.JacksonException.class, () -> mapper.writeValueAsString(data));
    System.out.println("❌ Joda doesn't work without JodaModule");
}

There are many changes in default configurations and other aspects. To save our time, I'll leave review comments with references to these changes in upcoming PRs!

@anthologia
Copy link
Contributor Author

Thanks for the feedback! Let me clarify my approach for Work 2 and Work 3:

Work 2 would implement the Jackson 3 counterparts like:

  • Jackson3JsonObjectMapper
  • Jackson3JsonMessageParser
  • JacksonJsonUtils, JacksonPresent
  • ...

Work 3 would then use these new components in places like ConfigurableCompositeMessageConverter:

if (JacksonPresent.isJackson3Present()) { // here
    ObjectMapper objectMapper = new Jackson3JsonObjectMapper().getObjectMapper(); // here
    JacksonJsonMessageConverter jacksonJsonMessageConverter = new JacksonJsonMessageConverter(objectMapper);
    // ...
}

@artembilan
Copy link
Member

Thanks for clarification!
Sounds like a plan !
Let’s give it a shot!

@artembilan artembilan added this to the 7.0.0-M1 milestone Jun 23, 2025
@artembilan artembilan merged commit 5cebdeb into spring-projects:main Jun 23, 2025
3 checks passed
@anthologia anthologia deleted the GH-10058 branch June 23, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants