You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2020/05/06 15:20:00 UTC

[openmeetings] branch master updated: [OPENMEETINGS-2301] there should be no ghost users

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new ea62bd3  [OPENMEETINGS-2301] there should be no ghost users
     new 87b7629  Merge branch 'master' of github.com:apache/openmeetings
ea62bd3 is described below

commit ea62bd30cbc6ba5136a9a72ef167028eb6ab8ba3
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Wed May 6 22:18:48 2020 +0700

    [OPENMEETINGS-2301] there should be no ghost users
---
 .../openmeetings/core/util/WebSocketHelper.java    | 38 ++++++++--------------
 .../openmeetings/db/entity/basic/Client.java       |  7 ++--
 .../apache/openmeetings/web/app/ClientManager.java |  3 +-
 pom.xml                                            |  2 +-
 4 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
index 30d9750..c75254f 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
@@ -63,7 +63,6 @@ public class WebSocketHelper {
 				} catch (Throwable e) {
 					log.error("Error while sending binary message to client", e);
 				}
-				checkClosed(c, omClient);
 			});
 		}
 	}
@@ -77,36 +76,25 @@ public class WebSocketHelper {
 				} catch (Throwable e) {
 					log.error("Error while sending message to client", e);
 				}
-				checkClosed(c, omClient);
 			});
 		}
 	}
 
-	private static void checkClosed(IWebSocketConnection c, final IWsClient omClient) {
-		if (c.isOpen()) {
-			return;
-		}
-		log.error("!!!!WS connection is closed in sendMessage");
-		WebSocketSettings settings = WebSocketSettings.Holder.get((Application)getApp());
-		IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
-		reg.removeConnection(c.getApplication(), c.getSessionId(), c.getKey());
-		if (omClient instanceof Client) {
-			getApp().getBean(IClientManager.class).exit((Client)omClient);
-		}
-	}
 	public static IApplication getApp() {
 		return (IApplication)Application.get(getWicketApplicationName());
 	}
 
 	private static void sendClient(IWsClient client, Consumer<IWebSocketConnection> wsc) {
-		Application app = (Application)getApp();
-		WebSocketSettings settings = WebSocketSettings.Holder.get(app);
-		IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
-		Executor executor = settings.getWebSocketPushMessageExecutor();
-		final IWebSocketConnection wc = reg.getConnection(app, client.getSessionId(), new PageIdKey(client.getPageId()));
-		if (wc != null && wc.isOpen()) {
-			executor.run(() -> wsc.accept(wc));
-		}
+		new Thread(() -> {
+			Application app = (Application)getApp();
+			WebSocketSettings settings = WebSocketSettings.Holder.get(app);
+			IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
+			Executor executor = settings.getWebSocketPushMessageExecutor();
+			final IWebSocketConnection wc = reg.getConnection(app, client.getSessionId(), new PageIdKey(client.getPageId()));
+			if (wc != null && wc.isOpen()) {
+				executor.run(() -> wsc.accept(wc));
+			}
+		}).start();
 	}
 
 	public static boolean send(IClusterWsMessage msg) {
@@ -205,8 +193,10 @@ public class WebSocketHelper {
 			WebSocketSettings settings = WebSocketSettings.Holder.get(app);
 			IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
 			Executor executor = settings.getWebSocketPushMessageExecutor();
-			for (IWebSocketConnection c : reg.getConnections(app)) {
-				executor.run(() -> sender.accept(c));
+			for (IWebSocketConnection wc : reg.getConnections(app)) {
+				if (wc != null && wc.isOpen()) {
+					executor.run(() -> sender.accept(wc));
+				}
 			}
 		}).start();
 	}
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
index 1b4d8dc..46166aa 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
@@ -37,7 +37,6 @@ import org.apache.openmeetings.db.entity.IDataProviderEntity;
 import org.apache.openmeetings.db.entity.room.Room;
 import org.apache.openmeetings.db.entity.room.Room.Right;
 import org.apache.openmeetings.db.entity.user.User;
-import org.apache.wicket.util.collections.ConcurrentHashSet;
 import org.apache.wicket.util.string.Strings;
 
 import com.github.openjson.JSONArray;
@@ -68,8 +67,8 @@ public class Client implements IDataProviderEntity, IWsClient {
 	private final String uid;
 	private final String sid;
 	private String remoteAddress;
-	private final Set<Right> rights = new ConcurrentHashSet<>();
-	private final Set<Activity> activities = new ConcurrentHashSet<>();
+	private final Set<Right> rights = ConcurrentHashMap.newKeySet();
+	private final Set<Activity> activities = ConcurrentHashMap.newKeySet();
 	private final Map<String, StreamDesc> streams = new ConcurrentHashMap<>();
 	private final Date connectedSince;
 	private int cam = -1;
@@ -448,7 +447,7 @@ public class Client implements IDataProviderEntity, IWsClient {
 
 	public class StreamDesc implements Serializable {
 		private static final long serialVersionUID = 1L;
-		private final Set<Activity> sactivities = new ConcurrentHashSet<>();
+		private final Set<Activity> sactivities = ConcurrentHashMap.newKeySet();
 		private final String uuid;
 		private final StreamType type;
 		private int swidth;
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 7806af1..c413b61 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
@@ -49,7 +49,6 @@ import org.apache.openmeetings.db.util.ws.RoomMessage;
 import org.apache.openmeetings.db.util.ws.TextRoomMessage;
 import org.apache.openmeetings.web.pages.auth.SignInPage;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.collections.ConcurrentHashSet;
 import org.apache.wicket.util.string.StringValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -262,7 +261,7 @@ public class ClientManager implements IClientManager {
 		log.debug("Adding online room client: {}, room: {}", c.getUid(), roomId);
 		IMap<Long, Set<String>> rooms = rooms();
 		rooms.lock(roomId);
-		rooms.putIfAbsent(roomId, new ConcurrentHashSet<String>());
+		rooms.putIfAbsent(roomId, ConcurrentHashMap.newKeySet());
 		Set<String> set = rooms.get(roomId);
 		set.add(c.getUid());
 		final int count = set.size();
diff --git a/pom.xml b/pom.xml
index 8f65d6d..4255a95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,7 +76,7 @@
 		<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
 		<!-- dependency versions -->
 		<junit.version>5.6.2</junit.version>
-		<wicket.version>9.0.0-M5</wicket.version>
+		<wicket.version>9.0.0-M6-SNAPSHOT</wicket.version>
 		<wicketju.version>9.0.0-M5.1</wicketju.version>
 		<wickets.version>9.0.0-M5.1</wickets.version>
 		<wicket-bootstrap.version>5.0.0-M2</wicket-bootstrap.version>