Skip to content

Removal of JAXB annotations - #1807

Merged
jeandersonbc merged 1 commit into
mainfrom
initial-migration-jaxb
Apr 7, 2026
Merged

Removal of JAXB annotations#1807
jeandersonbc merged 1 commit into
mainfrom
initial-migration-jaxb

Conversation

@jeandersonbc

@jeandersonbc jeandersonbc commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

Removal the JAXB-bind related annotations. This change is needed due to Jakarta EE +9 compatibility.
In addition, we Improved type safety for AuthenticatedData.keyTransportOrKEK deserialization**:

Previously, items in the keyTransportOrKEK list were deserialized as raw Object (a Gson LinkedTreeMap at runtime), requiring brittle map access to read fields. The TerminalAPIGsonBuilder now registers a custom adapter that detects the concrete type of each list item at deserialization time — objects containing a KEKIdentifier field are deserialized as KEK, all others as KeyTransport. This makes safe casting possible:

 // After
 AuthenticatedData data = gson.fromJson(json, AuthenticatedData.class);

 // Cast to KEK
 KEK kek = (KEK) data.getKeyTransportOrKEK().get(0);
 String keyId = kek.getKEKIdentifier().getKeyIdentifier();

 // Cast to KeyTransport
 KeyTransport kt = (KeyTransport) data.getKeyTransportOrKEK().get(0);
 RecipientIdentifier recipient = kt.getRecipientIdentifier();

Further details:

Since the underlying serializer relies on Gson lib, we are unable to use directly Jackson annotations since they don't work as expected. This was verified via test coverage. Furthermore, the required=true validation was never enforced (see AbortRequestTest tests).

The existing code in com.adyen.terminal.serialization relies on GSON; thus,the JAXB annotations were replaced by the GSON's @SerializedName.

The migration was guided by test coverage and focused on serialization and deserialization of JSON payloads.

POM XML changes:

  • removal of jaxb dependency
  • addition of plugin enforcement to block unwanted dependencies

Tested scenarios

  • Serialization/Deserialization from external file
  • Missing required fields (that are not enforced in practice)

@jeandersonbc jeandersonbc self-assigned this Mar 27, 2026
@jeandersonbc
jeandersonbc requested review from a team as code owners March 27, 2026 09:23

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

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.

Code Review

This pull request migrates several Nexo model classes, including AbortRequest, DisplayRequest, LoginRequest, and MessageHeader, from JAXB XML annotations to GSON @SerializedName annotations. The changes also involve removing JAXB-specific metadata and adding unit tests to verify that serialization and deserialization remain functional even when fields previously marked as required are missing from the JSON payload. I have no feedback to provide.

@gcatanese
gcatanese self-requested a review March 27, 2026 10:05
@thomas-cools

Copy link
Copy Markdown

@jeandersonbc is my understanding correct that we were using the jaxb annotation with GSON as the serializer / deserializer, so there is no actual change in behavior other than using GSON annotations?

@jeandersonbc

Copy link
Copy Markdown
Contributor Author

@jeandersonbc is my understanding correct that we were using the jaxb annotation with GSON as the serializer / deserializer, so there is no actual change in behavior other than using GSON annotations?

Correct @thomas-cools (cc @gcatanese)! I also pushed this test that verifies how GSON handles the JAXB annotations. The target class (EventNotification) has not been migrated and has some required=true fields. If those checks were really enforced, EventNotificationTest would have failed.

I'm going to proceed to JAXB -> Gson annontations as part of the original task.

thomasc-adyen
thomasc-adyen previously approved these changes Mar 27, 2026
@jeandersonbc
jeandersonbc force-pushed the initial-migration-jaxb branch from 34c0d98 to 4ade44d Compare April 2, 2026 08:33
@jeandersonbc jeandersonbc changed the title Initial migration away from JAXB annotations Removal of JAXB annotations Apr 2, 2026
@jeandersonbc
jeandersonbc enabled auto-merge April 2, 2026 08:59
@jeandersonbc
jeandersonbc force-pushed the initial-migration-jaxb branch from 4ade44d to f0f5cce Compare April 2, 2026 09:15

@gcatanese gcatanese left a comment

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.

Great work Jean, this is a challenging issue.

I left few comments in the code and there is here one about test coverage, they might be edge cases so please assess whether they are applicable or not

Test Coverage Gaps

• No direct unit tests for XMLEnumTypeAdapter with @SerializedName, especially the edge case where the annotation is absent on an enum constant.
• No round-trip tests for SaleToPOIRequest — only SaleToPOIResponse is covered despite the same migration pattern.
RepeatedMessageResponseBody / RepeatedResponseMessageBody — migrated but zero test coverage.
TerminalAPIGsonBuilder fallback behavior — no test verifying the behavior when @SerializedName is missing.

Comment thread src/main/java/com/adyen/terminal/serialization/TerminalAPIGsonBuilder.java Outdated
Comment thread src/main/java/com/adyen/model/nexo/AuthenticatedData.java
Comment thread src/main/java/com/adyen/model/nexo/AuthenticatedData.java
@jeandersonbc
jeandersonbc force-pushed the initial-migration-jaxb branch from f0f5cce to e0d6100 Compare April 3, 2026 13:48
This PR removes the JAXB-bind related annotations. This change is needed due to Jakarta EE +9
compatibility. The existing code in `com.adyen.terminal.serialization` relies on GSON; thus,
the JAXB annotations were replaced by the GSON's @SerializedName.

The JAXB validations (e.g., type checks and required fields) were not processed by GSON and
have no equivalent (see `AbortRequestTest` for instance).

The migration was guided by test coverage and focused on serialization and deserialization of
JSON payloads.

POM XML changes:
- removal of jaxb dependency
- addition of plugin enforcement to block unwanted dependencies
@jeandersonbc
jeandersonbc force-pushed the initial-migration-jaxb branch from e0d6100 to e6a3ee3 Compare April 7, 2026 13:30
@jeandersonbc
jeandersonbc added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit 7da93b7 Apr 7, 2026
5 checks passed
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.

4 participants