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/MQTTEventAdapter.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/MQTTEventAdapter.java index 76239163bb..21381e722b 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/MQTTEventAdapter.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/MQTTEventAdapter.java @@ -84,8 +84,10 @@ public class MQTTEventAdapter implements InputEventAdapter { .equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { return; } - if (!mqttAdapterListener.isConnectionInitialized()) { - mqttAdapterListener.createConnection(); + synchronized (this.mqttAdapterListener) { + if (!mqttAdapterListener.isConnectionInitialized()) { + mqttAdapterListener.createConnection(); + } } } @@ -102,8 +104,10 @@ public class MQTTEventAdapter implements InputEventAdapter { if (ServerStatus.getCurrentStatus().equals(ServerStatus.STATUS_SHUTTING_DOWN)) { Thread thread = new Thread(new Runnable() { public void run() { - if (mqttAdapterListener != null) { - mqttAdapterListener.stopListener(eventAdapterConfiguration.getName()); + synchronized (mqttAdapterListener) { + if (mqttAdapterListener != null) { + mqttAdapterListener.stopListener(eventAdapterConfiguration.getName()); + } } } }); diff --git a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml index 3334bfafee..bcd8f8bdb7 100644 --- a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml +++ b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml @@ -99,7 +99,8 @@ org.wso2.carbon.user.api, org.wso2.carbon.core, org.wso2.carbon.device.mgt.core.config, - org.wso2.carbon.device.mgt.core.config.pull.notification + org.wso2.carbon.device.mgt.core.config.pull.notification, + org.wso2.carbon.utils.multitenancy