diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbRoomRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbRoomRepository.java index fe5e439ba2f42a366a3fd70245525ccdb1cb3eba..10f2c44fee386d478ec71d5064e174f57af79f95 100644 --- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbRoomRepository.java +++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbRoomRepository.java @@ -58,6 +58,9 @@ public class CouchDbRoomRepository extends CouchDbCrudRepository<Room> implement @Override public Room findByShortId(final String shortId) { + if (shortId == null) { + return null; + } final List<Room> roomList = queryView("by_shortid", shortId); return !roomList.isEmpty() ? roomList.get(0) : null; diff --git a/src/main/java/de/thm/arsnova/services/RoomServiceImpl.java b/src/main/java/de/thm/arsnova/services/RoomServiceImpl.java index 005d846b97aac58b768f4df13e2aa7a90338ad4c..0a3c7322687c930bef54d0db8070bd0311da0e6f 100644 --- a/src/main/java/de/thm/arsnova/services/RoomServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/RoomServiceImpl.java @@ -201,6 +201,9 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R @Override @Cacheable("room.id-by-shortid") public String getIdByShortId(final String shortId) { + if (shortId == null) { + throw new NullPointerException("shortId cannot be null"); + } Room room = roomRepository.findByShortId(shortId); if (room == null) { throw new NotFoundException("No Room exists for short ID"); diff --git a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java index 31f7d3d52bcdeb80c3870f50fe8aef6c8a5eebfe..cffb662237350f1b4316e8d9afef572150defb4e 100644 --- a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java +++ b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java @@ -172,16 +172,18 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova return; } final String oldRoomId = userService.getRoomIdByUserId(u.getId()); - if (null != room.getKeyword() && room.getKeyword().equals(oldRoomId)) { - return; - } - final String roomId = roomService.getIdByShortId(room.getKeyword()); + if (null != room.getKeyword()) { + if (room.getKeyword().equals(oldRoomId)) { + return; + } + final String roomId = roomService.getIdByShortId(room.getKeyword()); - if (null != roomId && null != roomService.join(roomId, client.getSessionId())) { - /* active user count has to be sent to the client since the broadcast is - * not always sent as long as the polling solution is active simultaneously */ - reportActiveUserCountForRoom(roomId); - reportRoomDataToClient(roomId, u, client); + if (null != roomId && null != roomService.join(roomId, client.getSessionId())) { + /* active user count has to be sent to the client since the broadcast is + * not always sent as long as the polling solution is active simultaneously */ + reportActiveUserCountForRoom(roomId); + reportRoomDataToClient(roomId, u, client); + } } if (null != oldRoomId) { reportActiveUserCountForRoom(oldRoomId);