From 0c4f575e376e509e57e0d1bc617500449e5be047 Mon Sep 17 00:00:00 2001 From: Ali Reza Zamani Zadeh Najari Date: Tue, 11 Feb 2020 16:51:25 -0800 Subject: [PATCH] Comment fixes --- .../java/org/apache/helix/task/TaskUtil.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/task/TaskUtil.java b/helix-core/src/main/java/org/apache/helix/task/TaskUtil.java index 145ee23bb9..072785feff 100644 --- a/helix-core/src/main/java/org/apache/helix/task/TaskUtil.java +++ b/helix-core/src/main/java/org/apache/helix/task/TaskUtil.java @@ -1040,8 +1040,6 @@ public static void purgeExpiredJobs(String workflow, WorkflowConfig workflowConf /** * The function that loops through the all existing workflow contexts and removes IdealState and * workflow context of the workflow whose workflow config does not exist. - * Try-catch has been used to avoid concurrent modification exception while doing deep copy. Since - * Map.keySet() can produce concurrent modification exception. * @param dataProvider * @param manager */ @@ -1049,12 +1047,18 @@ public static void workflowGarbageCollection(final WorkflowControllerDataProvide final HelixManager manager) { // Garbage collections for conditions where workflow context exists but config is missing. - Set existingWorkflowContexts; + Set existingContexts; + /* + * Here try-catch is used to avoid concurrent modification exception while doing deep copy. + * Map.keySet() can produce concurrent modification exception. + * Reason: If the map is modified while an iteration over the set is in progress, concurrent + * modification exception will be thrown. + */ try { - existingWorkflowContexts = new HashSet<>(dataProvider.getContexts().keySet()); + existingContexts = new HashSet<>(dataProvider.getContexts().keySet()); } catch (Exception e) { LOG.warn( - "Exception occurred while creating a list of all existing contexts with missing config!", + "Exception occurred while creating a list of all workflow/job context names!", e); return; } @@ -1062,7 +1066,7 @@ public static void workflowGarbageCollection(final WorkflowControllerDataProvide // toBeDeletedWorkflows is a set that contains the name of the workflows that their contexts // should be deleted. Set toBeDeletedWorkflows = new HashSet<>(); - for (String entry : existingWorkflowContexts) { + for (String entry : existingContexts) { WorkflowConfig cfg = dataProvider.getWorkflowConfig(entry); WorkflowContext ctx = dataProvider.getWorkflowContext(entry); if (ctx != null && ctx.getId().equals(TaskUtil.WORKFLOW_CONTEXT_KW) && cfg == null) {