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/03/30 15:44:33 UTC

[openmeetings] branch 4.0.x updated: [OPENMEETINGS-2202] NPE should be fixed

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 2630c6a  [OPENMEETINGS-2202] NPE should be fixed
2630c6a is described below

commit 2630c6ad30fc26cc890944e0d728c835762352c1
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Mon Mar 30 22:44:20 2020 +0700

    [OPENMEETINGS-2202] NPE should be fixed
---
 .../main/java/org/apache/openmeetings/db/entity/basic/Client.java | 6 +++++-
 .../main/java/org/apache/openmeetings/web/app/ClientManager.java  | 8 ++++----
 .../src/main/java/org/apache/openmeetings/web/room/RoomPanel.java | 2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)

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 2c848e4..52f7bf1 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
@@ -120,7 +120,11 @@ public class Client implements IClient {
 
 	@Override
 	public Long getUserId() {
-		return user.getId();
+		return user == null ? null : user.getId();
+	}
+
+	public boolean sameUserId(Long userId) {
+		return getUserId() == null ? false : getUserId().equals(userId);
 	}
 
 	@Override
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 129bd08..412e864 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
@@ -226,7 +226,7 @@ public class ClientManager implements IClientManager {
 	public boolean isOnline(Long userId) {
 		boolean isUserOnline = false;
 		for (Map.Entry<String, Client> e : map().entrySet()) {
-			if (e.getValue().getUserId().equals(userId)) {
+			if (e.getValue().sameUserId(userId)) {
 				isUserOnline = true;
 				break;
 			}
@@ -270,7 +270,7 @@ public class ClientManager implements IClientManager {
 		for (Entry<Long, Set<String>> me : onlineRooms.entrySet()) {
 			for (String uid : me.getValue()) {
 				Client c = get(uid);
-				if (c != null && c.getUserId().equals(userId)) {
+				if (c != null && c.sameUserId(userId)) {
 					result.add(me.getKey());
 				}
 			}
@@ -283,7 +283,7 @@ public class ClientManager implements IClientManager {
 		if (clients != null) {
 			for (String uid : clients) {
 				Client c = get(uid);
-				if (c != null && c.getUserId().equals(userId)) {
+				if (c != null && c.sameUserId(userId)) {
 					return true;
 				}
 			}
@@ -293,7 +293,7 @@ public class ClientManager implements IClientManager {
 
 	private List<Client> getByKeys(Long userId, String sessionId) {
 		return map().values().stream()
-				.filter(c -> c.getUserId().equals(userId) && c.getSessionId().equals(sessionId))
+				.filter(c -> c.sameUserId(userId) && c.getSessionId().equals(sessionId))
 				.collect(Collectors.toList());
 	}
 
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
index 3318ebf..ac8677f 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
@@ -678,7 +678,7 @@ public class RoomPanel extends BasePanel {
 
 	public static boolean hasRight(long userId, long roomId, Right r) {
 		for (Client c : getBean(ClientManager.class).listByRoom(roomId)) {
-			if (c.getUserId().equals(userId) && c.hasRight(r)) {
+			if (c.sameUserId(userId) && c.hasRight(r)) {
 				return true;
 			}
 		}