From 76a442e864f43b77dc6b4d1ad7e285a276a77335 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 17 Aug 2016 15:54:56 +0530 Subject: [PATCH 1/3] Fix for possible NPE that could happen due to null device or null property list. --- .../mgt/mobile/util/MobileDeviceManagementUtil.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index d23bab34b..b70019f3e 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -73,11 +73,13 @@ public class MobileDeviceManagementUtil { } private static String getPropertyValue(Device device, String property) { - for (Device.Property prop : device.getProperties()) { - if (property.equals(prop.getName())) { - return prop.getValue(); - } - } + if (device != null && device.getProperties() != null) { + for (Device.Property prop : device.getProperties()) { + if (property.equals(prop.getName())) { + return prop.getValue(); + } + } + } return null; } From 8ba69c8b36dbe6ba470746c4a21b1afb0e48026f Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 17 Aug 2016 15:58:02 +0530 Subject: [PATCH 2/3] Change indentations to tab as this file use tab indentations --- .../mobile/util/MobileDeviceManagementUtil.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index b70019f3e..744c5ce0c 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -73,13 +73,13 @@ public class MobileDeviceManagementUtil { } private static String getPropertyValue(Device device, String property) { - if (device != null && device.getProperties() != null) { - for (Device.Property prop : device.getProperties()) { - if (property.equals(prop.getName())) { - return prop.getValue(); - } - } - } + if (device != null && device.getProperties() != null) { + for (Device.Property prop : device.getProperties()) { + if (property.equals(prop.getName())) { + return prop.getValue(); + } + } + } return null; } From 2f2af6c46bbb094f43bced194fc293b4cc6f0641 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 17 Aug 2016 15:58:32 +0530 Subject: [PATCH 3/3] Change indentations to tab as this file use tab indentations --- .../device/mgt/mobile/util/MobileDeviceManagementUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index 744c5ce0c..e97c0cb0d 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -76,7 +76,7 @@ public class MobileDeviceManagementUtil { if (device != null && device.getProperties() != null) { for (Device.Property prop : device.getProperties()) { if (property.equals(prop.getName())) { - return prop.getValue(); + return prop.getValue(); } } }