This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/4.0.x by this push:
new 5da9392 [OPENMEETINGS-2062] unenroll should work better
5da9392 is described below
commit 5da9392101c95c4504b89146351f91399660c3e1
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Fri Apr 26 14:16:15 2019 +0700
[OPENMEETINGS-2062] unenroll should work better
---
.../apache/openmeetings/web/app/ClientManager.java | 24 ++++++++--------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/ClientManager.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/ClientManager.java
index 08a954f..129bd08 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/ClientManager.java
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/ClientManager.java
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
@@ -290,26 +291,17 @@ public class ClientManager implements IClientManager {
return false;
}
- private Client getByKeys(Long userId, String sessionId) {
- Client client = null;
- for (Map.Entry<String, Client> e : map().entrySet()) {
- Client c = e.getValue();
- if (c.getUserId().equals(userId) &&
c.getSessionId().equals(sessionId)) {
- client = c;
- break;
- }
- }
- return client;
+ private List<Client> getByKeys(Long userId, String sessionId) {
+ return map().values().stream()
+ .filter(c -> c.getUserId().equals(userId) &&
c.getSessionId().equals(sessionId))
+ .collect(Collectors.toList());
}
public void invalidate(Long userId, String sessionId) {
- Client client = getByKeys(userId, sessionId);
- if (client != null) {
+ for (Client c : getByKeys(userId, sessionId)) {
Map<String, String> invalid =
Application.get().getInvalidSessions();
- if (!invalid.containsKey(client.getSessionId())) {
- invalid.put(client.getSessionId(),
client.getUid());
- exit(client);
- }
+ invalid.putIfAbsent(sessionId, c.getUid());
+ exit(c);
}
}