This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-4.0.x by this push:
     new 0046a030a5 Make LookupContext#closeables thread safe (#12411) (#12414)
0046a030a5 is described below

commit 0046a030a58f21a9ccb63bb57dd3108fbef81281
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Jul 3 12:55:39 2026 +0200

    Make LookupContext#closeables thread safe (#12411) (#12414)
    
    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 <[email protected]>
    Co-authored-by: Stefan Oehme <[email protected]>
---
 .../src/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 c3bbb98158..bf156b6949 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<AutoCloseable> closeables = new ArrayList<>();
+    public final List<AutoCloseable> closeables = 
Collections.synchronizedList(new ArrayList<>());
 
     @Override
     public void close() throws InvokerException {

Reply via email to