From c571546f60137a781bf808de9508d39db4f32053 Mon Sep 17 00:00:00 2001 From: Dmitry Kovba Date: Wed, 17 Sep 2025 09:49:30 -0700 Subject: [PATCH] Use a lock consistently in the `ExecutionContext` class (#619) The changes in this PR improve the consistency of using a lock in the `ExecutionContext` class. --- .../ExecutionContext.swift | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Sources/NativeBuilder/ContainerBuildExecutor/ExecutionContext.swift b/Sources/NativeBuilder/ContainerBuildExecutor/ExecutionContext.swift index 5b0f6b68..8ec81d31 100644 --- a/Sources/NativeBuilder/ContainerBuildExecutor/ExecutionContext.swift +++ b/Sources/NativeBuilder/ContainerBuildExecutor/ExecutionContext.swift @@ -175,17 +175,19 @@ public final class ExecutionContext: @unchecked Sendable { /// Create a child context for a nested execution. public func childContext(for stage: BuildStage) -> ExecutionContext { - lock.withLock { - ExecutionContext( - stage: stage, - graph: graph, - platform: platform, - reporter: reporter, - snapshotter: snapshotter, - baseEnvironment: Environment(_environment.variables), - baseConfig: _imageConfig - ) + let (environmentVars, imageConfig) = lock.withLock { + (_environment.variables, _imageConfig) } + + return ExecutionContext( + stage: stage, + graph: graph, + platform: platform, + reporter: reporter, + snapshotter: snapshotter, + baseEnvironment: Environment(environmentVars), + baseConfig: imageConfig + ) } // MARK: - Snapshotter Integration