openvidu-server: SessionManager concurrency fix for session not active. Catch onSessionClosed event exceptions

pull/419/head
pabloFuente 2020-03-29 21:22:41 +02:00
parent c4d2edf66e
commit c43f211dd1
2 changed files with 11 additions and 3 deletions

View File

@ -286,7 +286,10 @@ public abstract class SessionManager {
public Session storeSessionNotActive(Session sessionNotActive) { public Session storeSessionNotActive(Session sessionNotActive) {
final String sessionId = sessionNotActive.getSessionId(); final String sessionId = sessionNotActive.getSessionId();
this.sessionsNotActive.put(sessionId, sessionNotActive); if (this.sessionsNotActive.putIfAbsent(sessionId, sessionNotActive) != null) {
log.warn("Concurrent initialization of session {}", sessionId);
return this.sessionsNotActive.get(sessionId);
}
this.initializeCollections(sessionId); this.initializeCollections(sessionId);
return sessionNotActive; return sessionNotActive;
} }
@ -537,7 +540,12 @@ public abstract class SessionManager {
final String mediaNodeId = session.getMediaNodeId(); final String mediaNodeId = session.getMediaNodeId();
if (session.close(reason)) { if (session.close(reason)) {
try {
sessionEventsHandler.onSessionClosed(session.getSessionId(), reason); sessionEventsHandler.onSessionClosed(session.getSessionId(), reason);
} catch (Exception e) {
log.error("Error recording 'sessionDestroyed' event for session {}: {} - {}", session.getSessionId(),
e.getClass().getName(), e.getMessage());
}
} }
this.cleanCollections(session.getSessionId()); this.cleanCollections(session.getSessionId());

View File

@ -43,7 +43,7 @@ public class RpcNotificationService {
RpcConnection connection = new RpcConnection(t.getSession()); RpcConnection connection = new RpcConnection(t.getSession());
RpcConnection oldConnection = rpcConnections.putIfAbsent(participantPrivateId, connection); RpcConnection oldConnection = rpcConnections.putIfAbsent(participantPrivateId, connection);
if (oldConnection != null) { if (oldConnection != null) {
log.warn("Concurrent initialization of rpcSession #{}", participantPrivateId); log.warn("Concurrent initialization of rpcSession {}", participantPrivateId);
connection = oldConnection; connection = oldConnection;
} }
return connection; return connection;