From 4afb13a18808006bad9a107fce0389f9276302ed Mon Sep 17 00:00:00 2001 From: rudraneel-chakraborty Date: Wed, 4 Dec 2024 10:51:59 -0500 Subject: [PATCH] DATAGO-90245 bug fix --- .../manager/TerraformLogProcessingService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java index dd4ce055..636b05f4 100644 --- a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java +++ b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java @@ -10,6 +10,7 @@ import org.springframework.util.CollectionUtils; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -48,19 +49,21 @@ public CommandResult buildTfStateFileDeletionFailureResult(RuntimeException root .build(); } - public CommandResult buildTfCommandResult(List jsonLogs) { + public CommandResult buildTfCommandResult(List logsInJsonFormat) { - if (CollectionUtils.isEmpty(jsonLogs)) { + if (CollectionUtils.isEmpty(logsInJsonFormat)) { throw new IllegalArgumentException("No terraform logs were collected. Unable to process response."); } - List> successLogs = jsonLogs.stream() + // Copy the list to avoid modifying the original and to avoid concurrent modification exceptions + List jsonLogsCopy = new ArrayList<>(logsInJsonFormat); + List> successLogs = jsonLogsCopy.stream() .map(this::parseTfOutput) .filter(this::isApplyCompleteLog) .map(this::simplifyApplyCompleteLog) .toList(); - List> errorLogs = jsonLogs.stream() + List> errorLogs = jsonLogsCopy.stream() .map(this::parseTfOutput) .filter(this::isErrorLog) .map(this::simplifyApplyErroredLog)