Skip to content

Latest commit

 

History

History
51 lines (31 loc) · 2.74 KB

streams.md

File metadata and controls

51 lines (31 loc) · 2.74 KB

Complement methods that operate on collections in the providers in KeycloakSession with Stream

Motivation

Currently the providers (e.g. RealmProvider, ClientProvider) accessible (in)directly from KeycloakSession operate on List and similar collections.

Consequently, the List operations are realized in memory even when only needed temporarily to be later filtered out like in this piece of code.

Thus the stream variants of the methods should be created, with backward compatibility in mind. This means that to each method with a list signature, e.g.:

    List<ClientModel> getClients(RealmModel realm);

The change will be as follows:

    @Deprecated
    default List<ClientModel> getClients(RealmModel realm) { /* use getClientsStream */ }

    default Stream<ClientModel> getClientsStream(RealmModel realm) {
        return getClients(realm).stream();
    }

This way, existing implementations will be able to still work, but the message that stream variant is preferred would be stated via @Deprecated annotation.

Acceptance criteria

  • All interfaces mentioned above have Stream counterparts for operations that currently operate on collections.
  • REST endpoints preferentially use Stream<T> over the current collections.
  • JPA preferentially use streams for obtaining query results where applicable.

Milestones

M1 Proof of concept on client resources

Ensure that acceptance criteria are met on ClientProvider.

M2 Mark non-stream variants as @Deprecated

M2 Update the rest of the resources

  1. Ensure that acceptance criteria are met on RealmProvider.
  2. Ensure that acceptance criteria are met on UserProvider.
  3. Ensure that acceptance criteria are met on UserSessionProvider.