From b87d3898f699a923254a61c701709f5258faf8e9 Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Thu, 31 Aug 2017 16:59:43 +0530 Subject: [PATCH] Fixes for wso2/product-iots#1285 --- .../service/DeviceManagementProviderServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index a4afef2f48..d5f8707d4e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -2333,8 +2333,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.openConnection(); info = deviceInfoDAO.getDeviceInformation(device.getId()); DeviceLocation location = deviceInfoDAO.getDeviceLocation(device.getId()); - if (info != null) { - info.setLocation(location); + if (location != null) { + //There are some cases where the device-info is not updated properly. Hence returning a null value. + if (info != null) { + info.setLocation(location); + } else { + info = new DeviceInfo(); + info.setLocation(location); + } } } catch (DeviceDetailsMgtDAOException e) { String msg = "Error occurred while retrieving advance info of '" + device.getType() +