From fed4f72d4bec72c151f031a366b9e3d56fd30493 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 16 Nov 2015 17:41:07 +0530 Subject: [PATCH 1/3] Fixing the null pointer --- .../carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index 344de738978..598fd80b7e2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -249,7 +249,7 @@ public class MonitoringManagerImpl implements MonitoringManager { HashMap temp = policyDAO.getAppliedPolicyIds(); for (Integer id : deviceIDs) { - if (temp != null && temp.containsKey(id)) { + if (temp != null && !temp.isEmpty() && temp.containsKey(id)) { devicePolicyIdMap.put(id, temp.get(id)); } } From 700b308b452b99242de43da19c0496182364fd07 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 16 Nov 2015 17:44:30 +0530 Subject: [PATCH 2/3] Fixing the null pointer and removnig innactive devices being monitored --- .../org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } } From 271c4f76cb969bed95e6ce85ab2ab42a02a730c0 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 16 Nov 2015 18:08:21 +0530 Subject: [PATCH 3/3] Fixnig the null pointer isssue --- .../carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index a1d945c3568..1eb91150b80 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -229,7 +229,7 @@ public class MonitoringManagerImpl implements MonitoringManager { //int tenantId = PolicyManagerUtil.getTenantId(); Map deviceIds = new HashMap<>(); List complianceDatas = new ArrayList<>(); - HashMap devicePolicyIdMap = null; + HashMap devicePolicyIdMap = new HashMap<>(); try { PolicyManagementDAOFactory.openConnection();