diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java index 1a35ea4ebc9..6bc51da2bac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java @@ -43,7 +43,7 @@ import java.util.Map; */ public class DeviceStatusMonitoringTask implements Task { - private static Log log = LogFactory.getLog(DeviceStatusMonitoringTask.class); + private static final Log log = LogFactory.getLog(DeviceStatusMonitoringTask.class); private String deviceType; private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig; private int deviceTypeId = -1; @@ -70,7 +70,7 @@ public class DeviceStatusMonitoringTask implements Task { EnrolmentInfo enrolmentInfo; try { operationEnrolmentMappings = this.getOperationEnrolmentMappings(); - if (operationEnrolmentMappings.size() > 0) { + if (operationEnrolmentMappings != null && operationEnrolmentMappings.size() > 0) { lastActivities = this.getLastDeviceActivities(); } } catch (DeviceStatusTaskException e) { @@ -78,7 +78,7 @@ public class DeviceStatusMonitoringTask implements Task { } for (OperationEnrolmentMapping mapping:operationEnrolmentMappings) { long lastActivity = -1; - if (lastActivities.containsKey(mapping.getEnrolmentId())) { + if (lastActivities != null && lastActivities.containsKey(mapping.getEnrolmentId())) { lastActivity = lastActivities.get(mapping.getEnrolmentId()); } EnrolmentInfo.Status newStatus = this.determineDeviceStatus(mapping, lastActivity); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java index 682f59317dc..988be3f4d0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java @@ -39,13 +39,13 @@ import java.util.Map; */ public class DeviceStatusTaskManagerServiceImpl implements DeviceStatusTaskManagerService { - private static Log log = LogFactory.getLog(DeviceStatusTaskManagerServiceImpl.class); + private static final Log log = LogFactory.getLog(DeviceStatusTaskManagerServiceImpl.class); public static final String DEVICE_STATUS_MONITORING_TASK_TYPE = "DEVICE_STATUS_MONITORING"; static final String DEVICE_TYPE = "DEVICE_TYPE"; static final String DEVICE_TYPE_ID = "DEVICE_TYPE_ID"; static final String DEVICE_STATUS_TASK_CONFIG = "DEVICE_STATUS_TASK_CONFIG"; - private static String TASK_CLASS = DeviceStatusMonitoringTask.class.getName(); + private static final String TASK_CLASS = DeviceStatusMonitoringTask.class.getName(); @Override public void startTask(DeviceType deviceType, DeviceStatusTaskPluginConfig deviceStatusTaskConfig)