From cb9db4dd1d14b3c44559759e7113283a9b88c0e6 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 9 May 2017 16:16:14 +0530 Subject: [PATCH] fixed null pointer in the initial operations --- .../DeviceManagementProviderServiceImpl.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 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 6672311c3d..083b795a9d 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 @@ -2114,22 +2114,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv deviceIdentifiers.add(deviceIdentifier); if (init != null) { List initialOperations = init.getOperations(); - - for (String str : initialOperations) { - CommandOperation operation = new CommandOperation(); - operation.setEnabled(true); - operation.setType(Operation.Type.COMMAND); - operation.setCode(str); - try { - deviceManagementProviderService. - addOperation(deviceType, - operation, deviceIdentifiers); - } catch (OperationManagementException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" + deviceIdentifier.getId(), - e); - } catch (InvalidDeviceException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" + deviceIdentifier.getId(), - e); + if (initialOperations != null) { + for (String str : initialOperations) { + CommandOperation operation = new CommandOperation(); + operation.setEnabled(true); + operation.setType(Operation.Type.COMMAND); + operation.setCode(str); + try { + deviceManagementProviderService. + addOperation(deviceType, + operation, deviceIdentifiers); + } catch (OperationManagementException e) { + throw new DeviceManagementException( + "Unable to find the device with the id: '" + deviceIdentifier.getId(), + e); + } catch (InvalidDeviceException e) { + throw new DeviceManagementException( + "Unable to find the device with the id: '" + deviceIdentifier.getId(), + e); + } } } }