fix serializable exceptions
This commit is contained in:
parent
a0d275c850
commit
6054b69eec
2 changed files with 12 additions and 9 deletions
|
@ -21,6 +21,7 @@ import org.infinispan.Cache;
|
|||
import org.infinispan.client.hotrod.RemoteCache;
|
||||
import org.infinispan.context.Flag;
|
||||
import org.infinispan.stream.CacheCollectors;
|
||||
import org.infinispan.stream.SerializableSupplier;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.cluster.ClusterProvider;
|
||||
import org.keycloak.common.util.Time;
|
||||
|
@ -60,10 +61,12 @@ import org.keycloak.models.sessions.infinispan.util.InfinispanKeyGenerator;
|
|||
import org.keycloak.models.sessions.infinispan.util.InfinispanUtil;
|
||||
import org.keycloak.models.utils.SessionTimeoutHelper;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -413,19 +416,15 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
|
|||
return cache.entrySet().stream()
|
||||
.filter(UserSessionPredicate.create(realm.getId()))
|
||||
.map(Mappers.authClientSessionSetMapper())
|
||||
.flatMap(Mappers::toStream)
|
||||
.flatMap((Serializable & Function<Set<String>, Stream<? extends String>>)Mappers::toStream)
|
||||
.collect(
|
||||
countingGroupingCollector()
|
||||
CacheCollectors.serializableCollector(
|
||||
() -> Collectors.groupingBy(Function.identity(), Collectors.counting())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static Collector<String, ?, Map<String, Long>> countingGroupingCollector() {
|
||||
return CacheCollectors.serializableCollector(
|
||||
() -> Collectors.groupingBy(Function.identity(), Collectors.counting())
|
||||
);
|
||||
}
|
||||
|
||||
protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline) {
|
||||
protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline) {
|
||||
Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
|
||||
cache = CacheDecorators.skipCacheLoaders(cache);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.keycloak.models.sessions.infinispan.stream;
|
||||
|
||||
import org.infinispan.stream.SerializableSupplier;
|
||||
import org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper;
|
||||
import org.keycloak.models.sessions.infinispan.entities.AuthenticatedClientSessionEntity;
|
||||
import org.keycloak.models.sessions.infinispan.entities.LoginFailureEntity;
|
||||
|
@ -31,6 +32,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -146,4 +149,5 @@ public class Mappers {
|
|||
return new AuthClientSessionSetMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue