From 09cb5fd6a0976a166cf8efbef535490797acf56d Mon Sep 17 00:00:00 2001 From: Stefan Oehme Date: Fri, 3 Jul 2026 10:33:58 +0200 Subject: [PATCH] Make LookupContext#closeables thread safe (#12411) This collection is modified by multiple threads, e.g. the FastTerminal setup thread calling context.closeables.add(out::flush). This can result in closeables being lost and can make subsequent builds with the embedded runner fail. Signed-off-by: Stefan Oehme --- .../main/java/org/apache/maven/cling/invoker/LookupContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java index c3bbb9815852..bf156b69498d 100644 --- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java +++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupContext.java @@ -105,7 +105,7 @@ public LookupContext(InvokerRequest invokerRequest, boolean containerCapsuleMana public Settings effectiveSettings; public PersistedToolchains effectiveToolchains; - public final List closeables = new ArrayList<>(); + public final List closeables = Collections.synchronizedList(new ArrayList<>()); @Override public void close() throws InvokerException {