8000 fix: consolidating rest layer object mapper by shawkins · Pull Request #54909 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

fix: consolidating rest layer object mapper - #54909

Merged
vmuzikar merged 1 commit into
keycloak:mainfrom
shawkins:iss44159
Dec 2, 2026
Merged

vmuzikar merged 1 commit into
keycloak:mainfrom
shawkins:iss44159

Conversation

@shawkins
@shawkins shawkins commented Nov 9, 2026 •
Copy link
Copy Markdown
Contributor

Inverts our creation of the rest layer objectmapper, so that we are reusing the quarkus one. We could move our customizations to the application.properties.

This reduces our memory footprint a little and let's and users or support issues use quarkus properties to workaround serialization / deserialization issues if needed.

closes: #44159

Copilot AI 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.

🟡 Changes recommended

The patch contains a non-compiling ObjectReader call and unconditional Jackson overrides that prevent explicit Quarkus configuration from taking effect.

1 open issue
What changed in this PR

This PR consolidates REST-layer JSON handling around Quarkus’s managed ObjectMapper, reducing duplicate mapper instances while retaining Keycloak-specific configuration.

Changes:

  • Replaces the Quarkus mapper resolver with an ObjectMapperCustomizer.
  • Adds a shared mapper accessor to session factories, with a fallback for non-Quarkus runtimes.
  • Updates admin-v2 merge-patch handling and RESTEasy test setup to use the revised mapper APIs.
File Description
services/​src/​test/​java/​org/​keycloak/​services/​resteasy/​ResteasyKeycloakApplication.java Supplies an explicit mapper to the test resolver.
services/​src/​main/​java/​org/​keycloak/​services/​util/​ObjectMapperResolver.java Extracts reusable configuration and accepts an injected mapper.
services/​src/​main/​java/​org/​keycloak/​services/​DefaultKeycloakSessionFactory.java Adds lazy access to a shared fallback mapper.
rest/​admin-v2/​services/​src/​main/​java/​org/​keycloak/​rest/​admin/​api/​client/​DefaultClientApi.java Uses the shared mapper for merge-patch processing.
quarkus/​runtime/​src/​main/​java/​org/​keycloak/​quarkus/​runtime/​integration/​QuarkusKeycloakSessionFactory.java Retrieves the Quarkus-managed mapper.
quarkus/​runtime/​src/​main/​java/​org/​keycloak/​quarkus/​runtime/​integration/​jaxrs/​KeycloakObjectMapperCustomizer.java Applies Keycloak configuration through a Quarkus customizer.

Review effort: Balanced

@shawkins
shawkins force-pushed the iss44159 branch 2 times, most recently from f87d17b to 2a7d0f8 Compare November 10, 2026 19:23
@shawkins
shawkins force-pushed the iss44159 branch 2 times, most recently from b9ed14e to 9b76874 Compare November 10, 2026 22:00
@shawkins
shawkins marked this pull request as ready for review November 10, 2026 22:19
@shawkins
shawkins requested review from a team as code owners November 10, 2026 22:19
@shawkins
shawkins requested review from Pepo48 and vmuzikar and a balanced review from Copilot November 10, 2026 22:19
Copilot AI 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.

🔵 Needs a closer look

Regression coverage is missing for how the mapper customizations interact with quarkus.jackson.* overrides, including default unknown-field rejection, an explicit override, and continued trailing-token rejection in PATCH requests.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 11, 2026 13:39
Copilot AI 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.

🔵 Needs a closer look

The shared Quarkus mapper changes serializer selection and customizer precedence across REST and single-file exports, requiring runtime validation of configuration overrides and export/import compatibility unavailable in this source-only review.

No open issues 🎉

Review effort: Balanced

@shawkins
Copy link
Copy Markdown
Contributor Author

Updated to be more aggressive in consolidation.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:54
Copilot AI 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.

🟡 Changes recommended

The export writer inherits REST serialization overrides that can rename fields, producing backup files the importer rejects.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 23, 2026 14:47
Copilot AI 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.

🔵 Needs a closer look

The REST mapper replacement needs runtime validation with http-optimized-serializers, including extension representations and realm round trips, to confirm wire compatibility.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 23, 2026 15:58
Copilot AI 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.

🟢 Approval recommended

The JSON mapper consolidation has no active review issues.

No open issues 🎉

Review effort: Balanced

@shawkins
shawkins requested review from a team as code owners November 23, 2026 23:01
Copilot AI balanced review requested due to automatic review settings November 23, 2026 23:01
Copilot AI 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.

🟡 Changes recommended

The test does not wait for split-triggered reloads to finish before removing the cached entry, allowing a reload to restore it and cause flaky assertions or false-positive merge results.

1 open issue

Review effort: Balanced

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the JSON mapper consolidation.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.adapter.servlet.SAMLClockSkewAdapterTest#testTokenTimeIsValid

Keycloak CI - Adapter IT

org.jboss.arquillian.graphene.enricher.exception.PageObjectInitializationException: 
Can not instantiate Page Object 
class org.keycloak.testsuite.adapter.page.SalesPostClockSkewServlet
 declared in: 
org.keycloak.testsuite.adapter.servlet.SAMLClockSkewAdapterTest
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@shawkins shawkins added the status/hold PR should not be merged. On hold for later. label Nov 25, 2026
also consolidating the creation of other object mappers

closes: keycloak#44159
Signed-off-by: Steve Hawkins <shawkins@redhat.com>

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc
Copilot AI balanced review requested due to automatic review settings November 30, 2026 17:20
Copilot AI 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.

🔵 Needs a closer look

Switching to the Quarkus-managed mapper changes serializer/deserializer participation, requiring runtime validation of realm raw-JSON round trips and merge-patch update semantics with optimized serializers both enabled and disabled.

No open issues 🎉

Review effort: Balanced

@shawkins
Copy link
Copy Markdown
Contributor Author

@vmuzikar made the suggested edits.

@vmuzikar vmuzikar 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.

LGTM, thanks.

@vmuzikar
vmuzikar merged commit 160d19b into keycloak:main Dec 2, 2026
100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flaky-test status/hold PR should not be merged. On hold for later. team/cloud-native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhanced ObjectMapper instantiation for Client v2

4 participants

0