From a6f0a716816122ea773151971076baac48dc5410 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Wed, 26 Jun 2019 05:57:41 +0530 Subject: [PATCH] Check null of pending operations before updating status --- .../mdm/services/android/util/AndroidDeviceUtils.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java index a6c949957..12ac7ef61 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java @@ -582,9 +582,11 @@ public class AndroidDeviceUtils { throws DeviceManagementException { try { List pendingOperations = getPendingOperations(deviceIdentifier); - for (Operation operation : pendingOperations) { - operation.setStatus(Operation.Status.ERROR); - AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); + if (pendingOperations != null && !pendingOperations.isEmpty()) { + for (Operation operation : pendingOperations) { + operation.setStatus(Operation.Status.ERROR); + AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); + } } } catch (OperationManagementException e) { String msg = "Error occurred while retrieving pending operations to update operation statuses of " +