Skip to content

Remove javaxb dependency from HMACValidator#1802

Merged
jeandersonbc merged 2 commits intomainfrom
fix-hmacvalidator-javaxb
Mar 26, 2026
Merged

Remove javaxb dependency from HMACValidator#1802
jeandersonbc merged 2 commits intomainfrom
fix-hmacvalidator-javaxb

Conversation

@jeandersonbc
Copy link
Copy Markdown
Contributor

Description
Instead of using javaxb dependency, we can rely on the existing commons-codec for Hex operations.
This is needed for the removal of the javaxb dependency.
The changes are just a patch to the existing code.

In addition, the pom.xml was cleaned:

  • removal of unused plugin
  • reorganized dependencies and versions

Tested scenarios

  • existing tests must pass

@jeandersonbc jeandersonbc self-assigned this Mar 25, 2026
@jeandersonbc jeandersonbc requested review from a team as code owners March 25, 2026 15:24
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

- removed unused coveralls plugin
- moved plugin and dep versions to properties
- grouped depdencies (and versions) per scope
- remove redundant maven dependency scope
@jeandersonbc jeandersonbc force-pushed the fix-hmacvalidator-javaxb branch from 4fa1058 to deea412 Compare March 25, 2026 15:31
@jeandersonbc jeandersonbc enabled auto-merge March 25, 2026 15:40

<!-- Dependency Versions -->
<!-- Compile -->
<com.fasterxml.jackson-version>2.21.0</com.fasterxml.jackson-version>
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.

just noticing this, but why do we have gson and jackson in the same project?

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.

GSON only used by the TerminalAPI

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm also curious about this. We do use it for serialization and deserialization in a few places (.toJson/.fromJson):

I think as part of the bigger migration, we want to stick with a single JSON library.

Copy link
Copy Markdown
Contributor

@thomasc-adyen thomasc-adyen Mar 25, 2026

Choose a reason for hiding this comment

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

Answered my own question 😅

This library uses both serialization stacks for historical and compatibility reasons:
• Jackson is used broadly by the generated API models (com.adyen.model.*.JSON classes with ObjectMapper).
• Gson is still used in specific flows, especially Terminal API and webhook notification helpers (for example TerminalCloudAPI and NotificationRequest#fromJson/toJson).

Edit: forgot to refresh 😆

Copy link
Copy Markdown
Contributor

@gcatanese gcatanese left a comment

Choose a reason for hiding this comment

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

Good work. Some minor suggestions.

Could update the PR title: jaxb dependency is not removed as part of the PR

Run Spotless plugin to format the new test code

Hex.decodeHex(key); throws DecoderException (when there is an error), it is a good idea to explicitly wrap it as IllegalArgumentException instead.
Currently, a bad hex key would throw SignatureException, while IllegalArgumentException is the right one in this error scenario.

@jeandersonbc jeandersonbc force-pushed the fix-hmacvalidator-javaxb branch from deea412 to 091335d Compare March 25, 2026 16:39
This is needed to remove the dependency from javax.xml.bind
@jeandersonbc jeandersonbc force-pushed the fix-hmacvalidator-javaxb branch from 091335d to 429e98a Compare March 26, 2026 10:47
Comment on lines +75 to +76
} catch (DecoderException e) {
throw new IllegalArgumentException("Invalid Hex HMAC key: " + key);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added suggestion from @gcatanese

@jeandersonbc jeandersonbc requested a review from gcatanese March 26, 2026 12:51
@jeandersonbc jeandersonbc added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit 15b1f17 Mar 26, 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.

3 participants