Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@thomasdarimont
Copy link
Contributor

@thomasdarimont thomasdarimont commented Feb 10, 2026

  • Expose configured HTTP method from SimpleHttpRequest - needed by extensions / libraries that wants to enrich the SimpleHTTP call based on the configured method.
  • Use same ObjectMapper configuration as in JsonSerialization used by the deprecated SimpleHTTP to produce consistent json output.
  • Allow to configure the ObjectMapper to use by SimpleHttp - this enables custom JSON formats
  • Expose ObjectMapper factory methods in JsonSerialization - allows consistent JSON serialization.

Fixes #43701

Followup to #43702

@thomasdarimont thomasdarimont requested a review from a team as a code owner February 10, 2026 12:18
@thomasdarimont thomasdarimont force-pushed the issue/gh-43701-improve-simple-http branch 2 times, most recently from 591b51e to c67e3aa Compare February 10, 2026 12:23
- Expose configured HTTP method from SimpleHttpRequest
- Use same ObjectMapper configuration as in JsonSerialization used by the deprecated SimpleHTTP
- Allow to configure the ObjectMapper to use by SimpleHttp
- Expose ObjectMapper factory methods in JsonSerialization

Fixes keycloak#43701

Signed-off-by: Thomas Darimont <[email protected]>
Replace usage of deprecated method
```
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
```
with supported variant.

Signed-off-by: Thomas Darimont <[email protected]>
@thomasdarimont thomasdarimont force-pushed the issue/gh-43701-improve-simple-http branch from c67e3aa to cec658f Compare February 12, 2026 14:06
Co-authored-by: Martin Bartoš <[email protected]>
Signed-off-by: Thomas Darimont <[email protected]>
@thomasdarimont
Copy link
Contributor Author

Thanks @mabartos for taking a look! I intentially created a new instance to avoid potential mutations of the shared ObjectMapper to have an affect the SimpleHTTP json serialization, but perhaps that was not necessary.

I applied your suggestion to reuse the JsonSerialization.mapper reference directly.

I keep the createObjectMapper... factory methods public to allow users to make customizations to mappers that are based on the "default" mapper confgurations.

Copy link

@keycloak-github-bot keycloak-github-bot bot left a comment

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

@keycloak-github-bot
Copy link

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.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabled

Keycloak CI - Java Distribution IT (windows-latest - temurin - 21)

org.openqa.selenium.TimeoutException: 
Expected condition failed: waiting for value to contain (ignoring case) "sign in to". Current value: "AUTH_RESPONSE" (tried for 5 second(s) with 500 milliseconds interval)
Build info: version: '4.28.1', revision: '73f5ad48a2'
System info: os.name: 'Windows Server 2025', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.9'
Driver info: org.jboss.arquillian.drone.webdriver.htmlunit.DroneHtmlUnitDriver_ByGraphene
...

Report flaky test

Copy link
Contributor

@mabartos mabartos left a comment

Choose a reason for hiding this comment

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

@thomasdarimont LGTM, thanks!

@keycloak/core As it is your area, could you please check this simple PR? Thanks!

@stianst You were involved in the older PR related to this - do you wanna review it as well?

mapper.registerModule(new JavaTimeModule());
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for context for another reviewer - the setSerializationInclusion() is deprecated, and uses the setDefaultPropertyInclusion underhood (setSerializationInclusion -> setPropertyInclusion -> setDefaultPropertyInclusion).

So, ok from my side, as there should not be any behavioral changes provided here.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve SimpleHttp API

3 participants