From 41fc701009a033359a32b446c38dfd1e978d0a5a Mon Sep 17 00:00:00 2001 From: charitha Date: Tue, 2 Oct 2018 01:20:10 +0530 Subject: [PATCH] Fix incorrect logic (cherry picked from commit 2a1bcab) --- .../RemoteSessionManagementServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java index 6f24538f02..5de235d90d 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java @@ -131,12 +131,16 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme .getMaxMessageBufferSize()); session.setMaxIdleTimeout(RemoteSessionManagementDataHolder.getInstance().getMaxIdleTimeout()); - if (token != null && token.isEmpty()) { - log.error("Could not find a UUID related to the remote session."); + if (token == null || token.isEmpty()) { + String message = "Could not find a UUID related to the remote session."; + log.error(message); + throw new RemoteSessionManagementException(message); } else { String tenantDomain = RemoteSessionManagementDataHolder.getInstance().getUuidToTenantMap().remove(token); if (tenantDomain == null || tenantDomain.isEmpty()) { - log.error("Invalid UUID, could not create the remote session."); + String message = "Invalid UUID (" + token + "), could not create the remote session."; + log.error(message); + throw new RemoteSessionManagementException(message); } else { // create new device session initializeDeviceSession(session, tenantDomain, deviceType, deviceId, operationId, token);