diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java index 2fd0a5b07ec..cf803dec283 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -23,7 +23,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -90,7 +89,7 @@ public class MonitoringTask implements Task { PolicyManagementDataHolder.getInstance().getPolicyMonitoringService(deviceType.getName()); List devices = deviceManagementProviderService.getAllDevices(deviceType.getName()); if (monitoringService != null && !devices.isEmpty()) { - monitoringManager.addMonitoringOperation(devices); + List notifiableDevices = new ArrayList<>(); @@ -118,6 +117,7 @@ public class MonitoringTask implements Task { log.debug(device.getDeviceIdentifier()); } } + monitoringManager.addMonitoringOperation(notifiableDevices); monitoringService.notifyDevices(notifiableDevices); } }