Skip to content

feat: migrate from Jackson 2 to Jackson 3#1571

Draft
yvasyliev wants to merge 18 commits intorubenlagus:devfrom
yvasyliev:feature/jackson3
Draft

feat: migrate from Jackson 2 to Jackson 3#1571
yvasyliev wants to merge 18 commits intorubenlagus:devfrom
yvasyliev:feature/jackson3

Conversation

@yvasyliev
Copy link

@yvasyliev yvasyliev commented Feb 17, 2026

Caution

THIS PR IS IN PROGRESS. PLEASE DO NOT MERGE IT.

As part of #1561 suggestion, I'm creating this request to migrate TelegramBots from Jackson 2 to Jackson 3.

Changelist

Based on the Jackson 3 Migration Guide, the next changes were applied.

Cross-module

The following changes were applied to all modules:

  1. com.fasterxml.jackson.* Jackson 2 dependencies were replaced with a single tools.jackson.core Jackson 3 dependency.
  2. Bumped Lombok from 1.18.34 to edge-SNAPSHOT to make @Jacksonized annotation compatible with Jackson 3. (TODO: bump to stable version)
  3. Bumped JUnit from 5.12.2 to 6.0.3; added BOM import.
  4. Bumped Mockito from 5.12.0 to 5.21.0; added BOM import.
  5. Created lombok.config file to enable Jackson 3-compatible @Jacksonized configuration.
  6. Replaced com.fasterxml.jackson.* Jackson 2 package imports with tools.jackson.* Jackson 3 package imports where relevant across the code.
  7. Replaced Jackson 2 ObjectMapper with Jackson 3 JsonMapper (a core JSON reader/writer in Jackson 3) across the code.
  8. Replaced IOException with JacksonException (extends RuntimeException) in the throws lists and catch blocks where relevant across the code.
  9. Adjusted unit tests to work with Jackson 3 JsonMapper.

Module-specific

The following changes were applied to specific modules only:

telegrambots-meta

  1. Replaced org.telegram.telegrambots.meta.api.objects.InputFileSerializer with org.telegram.telegrambots.meta.api.objects.InputFileConverter.
  2. org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.serialization.InputMessageContentDeserializer was removed in favor of @com.fasterxml.jackson.annotation.JsonTypeInfo.
  3. Applied @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) to org.telegram.telegrambots.meta.api.objects.Contact and org.telegram.telegrambots.meta.api.objects.stories.StoryAreaPosition to make Jackson 3 ignore getters during serialization. Without it, Jackson 3 will create an extra field in a serialized object (e.g., vcard and VCard).
  4. Removed unused fields from org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException.

telegrambots-webhook

  1. Created org.telegram.telegrambots.webhook.Jackson3Mapper adapter class to enable Javalin work with Jackson 3. Javalin project doesn't support Jackson 3 out-of-the-box just yet,

telegrambots-abilities

  1. Created explicit PolymorphicTypeValidator configuration, because the default one doesn't pass all tests.

@yvasyliev
Copy link
Author

Hi @rubenlagus while we're waiting for the Lombok stable release, could you please start an initial review? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants