KEYCLOAK-18680 Always close result stream
This commit is contained in:
parent
a412bb7b99
commit
0cdce1340d
3 changed files with 6 additions and 5 deletions
|
@ -43,6 +43,7 @@ import org.keycloak.models.utils.KeycloakModelUtils;
|
|||
import javax.persistence.LockModeType;
|
||||
|
||||
import static org.keycloak.models.jpa.PaginationUtils.paginateQuery;
|
||||
import static org.keycloak.utils.StreamsUtil.closing;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||
|
@ -71,7 +72,7 @@ public class JPAPermissionTicketStore implements PermissionTicketStore {
|
|||
|
||||
TypedQuery query = entityManager.createQuery(querybuilder);
|
||||
|
||||
return query.getResultStream().count();
|
||||
return closing(query.getResultStream()).count();
|
||||
}
|
||||
|
||||
private List<Predicate> getPredicates(CriteriaBuilder builder,
|
||||
|
|
|
@ -284,8 +284,8 @@ public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientSc
|
|||
public Map<ClientModel, Set<String>> getAllRedirectUrisOfEnabledClients(RealmModel realm) {
|
||||
TypedQuery<Map> query = em.createNamedQuery("getAllRedirectUrisOfEnabledClients", Map.class);
|
||||
query.setParameter("realm", realm.getId());
|
||||
return query.getResultStream()
|
||||
.filter(s -> s.get("client") != null)
|
||||
return closing(query.getResultStream()
|
||||
.filter(s -> s.get("client") != null))
|
||||
.collect(
|
||||
Collectors.groupingBy(
|
||||
s -> new ClientAdapter(realm, em, session, (ClientEntity) s.get("client")),
|
||||
|
@ -903,7 +903,7 @@ public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientSc
|
|||
query.setParameter("clientId", client.getId());
|
||||
query.setParameter("defaultScope", defaultScope);
|
||||
|
||||
return query.getResultStream()
|
||||
return closing(query.getResultStream())
|
||||
.map(clientScopeId -> session.clientScopes().getClientScopeById(realm, clientScopeId))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(clientScope -> Objects.equals(clientScope.getProtocol(), clientProtocol))
|
||||
|
|
|
@ -294,7 +294,7 @@ public class JpaUserSessionPersisterProvider implements UserSessionPersisterProv
|
|||
|
||||
Set<String> removedClientUUIDs = new HashSet<>();
|
||||
|
||||
clientSessionQuery.getResultStream().forEach(clientSession -> {
|
||||
closing(clientSessionQuery.getResultStream()).forEach(clientSession -> {
|
||||
boolean added = addClientSessionToAuthenticatedClientSessionsIfPresent(userSession, clientSession);
|
||||
if (!added) {
|
||||
// client was removed in the meantime
|
||||
|
|
Loading…
Reference in a new issue