diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java index 635012538..e6e9fe700 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java @@ -206,8 +206,14 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { } try { mqttClient.subscribe(topic); + log.info("mqtt receiver subscribed to topic: " + topic); } catch (MqttException e) { log.error("Failed to subscribe to topic: " + topic + ", Retrying....."); + try { + mqttClient.disconnect(); + } catch (MqttException ex) { + // do nothing. + } return false; } return true; diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java index ad18ff6d1..4d85851a2 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java @@ -137,7 +137,7 @@ public class ThriftEventAdapterServiceComponent { String tenantDomain = credentials.getDomainName(); if (objects != null && objects.length > 0) { if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - String[] splitValues = ((String) objects[0]).split("@@"); + String[] splitValues = ((String) objects[0]).split("@"); if (splitValues.length > 1) { tenantDomain = splitValues[0]; } diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java index e158c726e..568c567ec 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java @@ -72,7 +72,7 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { private static final String UI_EXECUTE = "ui.execute"; private static Log log = LogFactory.getLog(DeviceAccessBasedMQTTAuthorizer.class); - AuthorizationConfigurationManager MQTTAuthorizationConfiguration; + private AuthorizationConfigurationManager MQTTAuthorizationConfiguration; private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0"; private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager"; private static final String CACHE_NAME = "mqttAuthorizationCache"; @@ -173,17 +173,15 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { } catch (FeignException e) { oAuthRequestInterceptor.resetApiApplicationKey(); if (e.getMessage().contains(GATEWAY_ERROR_CODE)) { - log.error("Failed to connect to the device authorization service."); + log.error("Failed to connect to the device authorization service.", e); } else { log.error(e.getMessage(), e); } - log.error(e.getMessage(), e); } + return false; } finally { PrivilegedCarbonContext.endTenantFlow(); } - - return false; } /**