- Status: Draft #1
- JIRA: KEYCLOAK-14011
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.
- 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.
Ensure that acceptance criteria are met on ClientProvider.
- Ensure that acceptance criteria are met on RealmProvider.
- Ensure that acceptance criteria are met on UserProvider.
- Ensure that acceptance criteria are met on UserSessionProvider.