diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 8219dbb4e76..0aad9bc7c2d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -848,16 +848,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } } - subscriptionDAO.addDeviceSubscription(username, subInsertingDeviceIds, subType, - Operation.Status.PENDING.toString(), applicationReleaseId, tenantId); if (!subUpdatingDeviceIds.isEmpty()) { subscriptionDAO.updateDeviceSubscription(username, subUpdatingDeviceIds, action, subType, Operation.Status.PENDING.toString(), applicationReleaseId, tenantId); } - subUpdatingDeviceIds.addAll(subInsertingDeviceIds); - if (!subUpdatingDeviceIds.isEmpty()) { + + if (!subInsertingDeviceIds.isEmpty()) { + subscriptionDAO.addDeviceSubscription(username, subInsertingDeviceIds, subType, + Operation.Status.PENDING.toString(), applicationReleaseId, tenantId); List deviceSubIds = new ArrayList<>( - subscriptionDAO.getDeviceSubIds(subUpdatingDeviceIds, applicationReleaseId, tenantId)); + subscriptionDAO.getDeviceSubIds(subInsertingDeviceIds, applicationReleaseId, tenantId)); subscriptionDAO.addOperationMapping(operationId, deviceSubIds, tenantId); } }