8000 Client streaming for admin api v2 by shawkins · Pull Request #47611 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Client streaming for admin api v2 - #47611

Merged
shawkins merged 5 commits into
keycloak:mainfrom
shawkins:client-streaming
May 27, 2026
Merged

shawkins merged 5 commits into
keycloak:mainfrom
shawkins:client-streaming

Conversation

@shawkins
@shawkins shawkins commented Mar 31, 2026 •
Copy link
Copy Markdown
Contributor

closes: #47542

In the end the most straight-forward solution seems to be making the logic Resteasy classic specific. I don't see that other stacks implement a proxy method, so realistically the only other thing we will need to worry about is resteasy reactive. For that to work, we'll need an RxInvoker (but simplied to resteasy reactive specifically).

The extra changes for ClientBuilderWrapper and ResteasyClassicClientProvider could alternatively go under #47582 - but I wanted to show here at least that we could consolidate to a single method for creating a ClientBuilder that would be default add the Stream logic.

cc @robson90

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.

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

@shawkins
shawkins force-pushed the client-streaming branch 3 times, most recently from e436488 to 52a43e0 Compare March 31, 2026 11:37
@shawkins
Copy link
Copy Markdown
Contributor Author

Marked most of the copilot reviews as not needed - we only care about ensuring that the inputstream is closed.

And while we don't and we don't expect an untyped Stream to be used in our api, there's no harm in accounting for it in the type handling, so that change was applied.

@shawkins
shawkins commented Apr 1, 2026
Copy link
Copy Markdown
Contributor Author

Should be ready for review. I didn't initially appriciate there is a difference registering something as an object vs a class, which means we need to keep the if / else when creating the client. It also means that any custom json handler must be an instance, not a class.

@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

@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.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.10'
Driver info: org.jboss.arquillian.drone.webdriver.htmlunit.DroneHtmlUnitDriver_ByGraphene
...

Report flaky test

@shawkins
Copy link
Copy Markdown
Contributor Author

This should be ready. It will need some kind of follow-up for the admin client docs that indicates any Streams accessed should be read completely or closed.

@vmuzikar
vmuzikar requested a review from michalvavrik May 22, 2026 18:02
if (token == JsonToken.END_ARRAY) {
return Stream.of();
}
if (token != JsonToken.START_OBJECT) {
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.

This won't work for anything else than streams of objects. Is that correct?

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.

Yes, that is the only payload expected with Stream<Object>

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.

Hmmm, I'm thinking if we need the support for streaming primitives as well, but probably not.

vmuzikar
vmuzikar previously approved these changes May 25, 2026
@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.

This looks good but I'd like to also get a review from @mposolda who is maintaining this.

@vmuzikar
vmuzikar requested a review from mposolda May 25, 2026 07:27
throw new IOException("Expected Object");
}

Class<?> elementType = Object.class;
@michalvavrik michalvavrik May 25, 2026 •
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are loosing type safety for things IMO should be an illegal state ex (raw, standalone wildcard, type variable and streams of lists). If you want to keep it as is, it is fine with me, but my preference would be to support what we want to support like Stream<ClientRepresentation> and fire exception for other scenarios.

On the other hand, I expect everything to be tested, hence anytime someone would actually use it with our client when the element was Object I'd expect something like ClassCastException downstream, so we will know one way or another.

well, that was waste of words 😀

@michalvavrik michalvavrik left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Pepo48
Pepo48 previously approved these changes May 25, 2026
@Pepo48 Pepo48 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. I tested it a bit and I have just one UX suggestion below. But it's not something that would block this PR from being merged.

Thanks Steve!

@shawkins
shawkins dismissed stale reviews from Pepo48 and vmuzikar via 56a636b May 26, 2026 13:19
@shawkins
shawkins requested a review from vmuzikar May 26, 2026 13:22
shawkins and others added 5 commits May 26, 2026 09:25
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
closes: keycloak#47542

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
…nt/spi/StreamMessageBodyReader.java

Co-authored-by: Peter Zaoral <pepo48@gmail.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
@shawkins
shawkins force-pushed the client-streaming branch from 56a636b to 5412c56 Compare May 26, 2026 13:37
@mposolda mposolda 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.

@shawkins I am fine with changes in this PR as long as everything is backwards compatible and testsuite is passing OK. Which seems to be the case :-)

Also curious if something needs to be changed in this documentation https://www.keycloak.org/securing-apps/admin-client ? It seems to me that everything on that page would be still valid and people will not need any update in their code once they upgrade to the newer version of java admin-client with your changes incorporated. Can you please confirm?

@shawkins
shawkins commented May 27, 2026 •
Copy link
Copy Markdown
Contributor Author

Also curious if something needs to be changed in this documentation https://www.keycloak.org/securing-apps/admin-client ? It seems to me that everything on that page would be still valid and people will not need any update in their code once they upgrade to the newer version of java admin-client with your changes incorporated. Can you please confirm?

That is correct, this pr isn't adding anything new to what a user needs to do for v1 - but it is clarifying some of the code to avoid any confusion.

I also created #47582 to further refine how we're creating the client and update the docs as necessary.

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

@shawkins Approving then, Thanks for the confirm!

@shawkins
shawkins merged commit 8d94475 into keycloak:main May 27, 2026
87 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
* demonstrates client side streaming

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* fix: adding client streaming support

closes: keycloak#47542

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>

* using onClose instead of the proxy close

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* Update integration/admin-client/src/main/java/org/keycloak/admin/client/spi/StreamMessageBodyReader.java

Co-authored-by: Peter Zaoral <pepo48@gmail.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>

---------

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Peter Zaoral <pepo48@gmail.com>
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.

Use client-side Streaming for admin api v2 in the Java client

7 participants

0