From d2ad8ac5798babc5b6f542724213a699484a787a Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Fri, 23 Feb 2024 13:34:24 +0530 Subject: [PATCH] Optimize based on review comments --- .../timeout/task/impl/OperationTimeoutTask.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java index 335e0b56d6..1ef473e4d1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java @@ -64,7 +64,7 @@ public class OperationTimeoutTask extends RandomlyAssignedScheduleTask { @Override protected void executeRandomlyAssignedTask() { -// this task will run only in one node when the deployment has multiple nodes + // this task will run only in one node when the deployment has multiple nodes String operationTimeoutTaskConfigStr = getProperty( OperationTimeoutTaskManagerServiceImpl.OPERATION_TIMEOUT_TASK_CONFIG); Gson gson = new Gson(); @@ -89,22 +89,22 @@ public class OperationTimeoutTask extends RandomlyAssignedScheduleTask { List activities = DeviceManagementDataHolder.getInstance().getOperationManager() .getActivities(deviceTypes, operationTimeoutConfig.getCode(), timeMillis, operationTimeoutConfig.getInitialStatus()); + String operationId; + Operation operation; for (Activity activity : activities) { + operationId = activity.getActivityId().replace("ACTIVITY_", ""); for (ActivityStatus activityStatus : activity.getActivityStatus()) { - String operationId = activity.getActivityId().replace("ACTIVITY_", ""); - Operation operation = DeviceManagementDataHolder.getInstance().getOperationManager() + operation = DeviceManagementDataHolder.getInstance().getOperationManager() .getOperation(Integer.parseInt(operationId)); operation.setStatus(Operation.Status.valueOf(operationTimeoutConfig.getNextStatus())); DeviceManagementDataHolder.getInstance().getOperationManager() .updateOperation(activityStatus.getDeviceIdentifier(), operation); } } - } catch (OperationManagementException e) { String msg = "Error occurred while retrieving operations."; log.error(msg, e); } - } }