Skip to content

feat: Replace Jackson with Gson for json (de) serialization#789

Open
ehsavoie wants to merge 3 commits intoa2aproject:0.3.x-compatfrom
ehsavoie:gson
Open

feat: Replace Jackson with Gson for json (de) serialization#789
ehsavoie wants to merge 3 commits intoa2aproject:0.3.x-compatfrom
ehsavoie:gson

Conversation

@ehsavoie
Copy link
Copy Markdown
Collaborator

Replacing Jackson with Gson for json (de)serialization

Fixes #<issue_number_goes_here> 🦕

ehsavoie and others added 3 commits April 10, 2026 14:54
Replace Jackson ObjectMapper with Gson throughout the codebase to eliminate
  Jackson dependency and provide custom serialization control.

Key Changes:
  - Created JsonUtil.java with Gson-based OBJECT_MAPPER singleton
  - Implemented 9 custom TypeAdapters for complex type handling:
    * OffsetDateTimeTypeAdapter - ISO-8601 datetime serialization
    * JSONRPCErrorTypeAdapter - Polymorphic error deserialization (12 error types)
    * ThrowableTypeAdapter - Avoids Java 17+ reflection restrictions
    * TaskStateTypeAdapter - Wire format enum serialization
    * RoleTypeAdapter - Message.Role enum handling
    * PartKindTypeAdapter - Part.Kind enum handling
    * PartTypeAdapter - Polymorphic Part deserialization (Text/File/Data)
    * StreamingEventKindTypeAdapter - Event type deserialization
    * FileContentTypeAdapter - FileWithBytes/FileWithUri discrimination
  - Added TaskSerializationTest with 21 comprehensive tests covering:
    * Round-trip serialization for all Task components
    * Direct JSON deserialization tests
    * All Part types and FileContent variants
  - Removed Jackson-specific deserializers and annotations
  - Updated all usages across 142 files (client, server, extras, tests)
  - Removed Jackson dependencies from spec/pom.xml

Technical Details:
  - Thread-safe singleton OBJECT_MAPPER with all adapters registered
  - Handles polymorphic types via two-pass parsing strategy
  - Maintains wire format compatibility with existing JSON-RPC protocol
  - Preserves null-safety with NullAway/JSpecify conventions

Breaking Changes: None - wire format remains compatible

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
@ehsavoie ehsavoie requested review from jmesnil and kabir April 10, 2026 13:25
@ehsavoie ehsavoie changed the title Gson feat: Replace jakson with Gson for json (de) serialization Apr 10, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the project from Jackson to Gson for JSON processing. It includes the addition of a new JsonUtil utility class, updates to various pom.xml files to replace Jackson dependencies with Gson, and updates to the codebase to use the new utility. The reviewer correctly identified that several Quarkus modules were left without a configured JSON provider after removing the Jackson dependencies, which would cause runtime issues.

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<artifactId>quarkus-resteasy</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-resteasy-jackson to quarkus-resteasy. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for RESTEasy. To ensure JSON serialization and deserialization work correctly with Gson in this Quarkus module, you should replace this with quarkus-resteasy-gson.

This same concern applies to other modules where quarkus-resteasy-jackson or quarkus-rest-client-jackson were replaced with their base artifact without specifying a Gson alternative, for example in:

  • extras/push-notification-config-store-database-jpa/pom.xml
  • extras/task-store-database-jpa/pom.xml
  • reference/common/pom.xml
  • reference/jsonrpc/pom.xml
  • reference/rest/pom.xml
  • tck/pom.xml

Please ensure all Quarkus modules that handle JSON are correctly configured with a Gson provider.

Suggested change
<artifactId>quarkus-resteasy</artifactId>
<artifactId>quarkus-resteasy-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<artifactId>quarkus-rest-client</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-client-jackson to quarkus-rest-client. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for the REST client. To ensure JSON serialization and deserialization work correctly with Gson in the tests for this module, you should replace this with quarkus-rest-client-gson.

Suggested change
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<artifactId>quarkus-rest-client</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-client-jackson to quarkus-rest-client. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for the REST client. To ensure JSON serialization and deserialization work correctly with Gson in the tests for this module, you should replace this with quarkus-rest-client-gson.

Suggested change
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<artifactId>quarkus-rest-client</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-client-jackson to quarkus-rest-client. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for the REST client. To ensure JSON serialization and deserialization work correctly with Gson in the tests for this module, you should replace this with quarkus-rest-client-gson.

Suggested change
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<artifactId>quarkus-rest-client</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-client-jackson to quarkus-rest-client. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for the REST client. To ensure JSON serialization and deserialization work correctly with Gson in the tests for this module, you should replace this with quarkus-rest-client-gson.

Suggested change
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<artifactId>quarkus-rest-client</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-client-jackson to quarkus-rest-client. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for the REST client. To ensure JSON serialization and deserialization work correctly with Gson in the tests for this module, you should replace this with quarkus-rest-client-gson.

Suggested change
<artifactId>quarkus-rest-client</artifactId>
<artifactId>quarkus-rest-client-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
<artifactId>quarkus-rest</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The dependency has been changed from quarkus-rest-jackson to quarkus-rest. This correctly removes the explicit Jackson integration, but it does not configure a JSON provider for RESTEasy. To ensure JSON serialization and deserialization work correctly with Gson in this module, you should replace this with quarkus-rest-gson.

Suggested change
<artifactId>quarkus-rest</artifactId>
<artifactId>quarkus-rest-gson</artifactId>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't exist

@kabir
Copy link
Copy Markdown
Collaborator

kabir commented Apr 10, 2026

@ehsavoie is the cloud deployment example expected?

@ehsavoie ehsavoie changed the title feat: Replace jakson with Gson for json (de) serialization feat: Replace Jackson with Gson for json (de) serialization Apr 10, 2026
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