diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 3c58c0c6e..0300dea48 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -59,7 +59,12 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { List complianceFeatures = new ArrayList(); // Parsing json string to get compliance features. - JsonElement jsonElement = new JsonParser().parse((String) compliancePayload); + JsonElement jsonElement; + if (compliancePayload instanceof String) { + jsonElement = new JsonParser().parse((String) compliancePayload); + } else { + throw new PolicyComplianceException("Invalid policy compliance payload"); + } JsonArray jsonArray = jsonElement.getAsJsonArray(); Gson gson = new Gson(); ComplianceFeature complianceFeature;