From ab61ba75cf1e05e0c79b298f4cacf128be1edc95 Mon Sep 17 00:00:00 2001 From: Maxim Gorbunkov Date: Tue, 7 Feb 2017 11:14:03 +0400 Subject: [PATCH] PL-8590 REST API throws server error if access token expired --- .../src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java b/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java index ff4f9140b8..cc2ff792b2 100644 --- a/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java +++ b/modules/core/src/com/haulmont/cuba/restapi/ServerTokenStoreImpl.java @@ -19,6 +19,7 @@ package com.haulmont.cuba.restapi; import com.haulmont.cuba.core.app.ClusterListener; import com.haulmont.cuba.core.app.ClusterListenerAdapter; import com.haulmont.cuba.core.app.ClusterManagerAPI; +import com.haulmont.cuba.security.global.NoUserSessionException; import com.haulmont.cuba.security.global.UserSession; import com.haulmont.cuba.security.sys.UserSessionManager; import org.slf4j.Logger; @@ -188,9 +189,10 @@ public class ServerTokenStoreImpl implements ServerTokenStore { authenticationToAccessTokenStore.remove(authenticationKey); UUID sessionId = tokenValueToSessionIdStore.remove(tokenValue); if (sessionId != null) { - UserSession session = userSessionManager.getSession(sessionId); - if (session != null) + try { + UserSession session = userSessionManager.getSession(sessionId); userSessionManager.removeSession(session); + } catch (NoUserSessionException ignored) {} } } }