You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2025/08/14 14:04:11 UTC
(maven-resolver) branch master updated: SmartExecutor: on classic pools TCCL must be delegated (#1553)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new b2c150ccd SmartExecutor: on classic pools TCCL must be delegated (#1553)
b2c150ccd is described below
commit b2c150ccd4e7d686ccbc1eb9be31742e0cb4f73c
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Aug 14 16:04:05 2025 +0200
SmartExecutor: on classic pools TCCL must be delegated (#1553)
When Maven/Resolver runs on older than Java 21, the classic thread pools are used, and TCCL must be delegated now that they are reused across session, otherwise lookup issues occurs as Plexus DI will filter components based on it.
As Maven ITs shows, on Java 17 the DAV related ITs fail. They load the DAV Wagon as build extension (from POM). This means that BF used pool is instantiated way before, and pooled threads TCCL are not "aware" of (later) loaded up build extension (IT failes are "no DAV transport available", while the extension _is loaded up_).
With this change locally the ITs pass OK on Java 17, while on Java 21 (where VTs are used) this was never an issue, as we use "one VT per task" and VT is dropped once done (they are not pooled).
Before SmartExecutors, this was not a problem in BF collector, as pools were created "in situ" and then thrown away, that was sub-optimal.
---
.../main/java/org/eclipse/aether/util/concurrency/SmartExecutor.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/SmartExecutor.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/SmartExecutor.java
index bc39c3d74..8ed47946b 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/SmartExecutor.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/SmartExecutor.java
@@ -82,12 +82,17 @@ public interface SmartExecutor extends AutoCloseable {
@Override
public <T> CompletableFuture<T> submit(Callable<T> callable) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
CompletableFuture<T> future = new CompletableFuture<>();
executor.submit(() -> {
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(tccl);
try {
future.complete(callable.call());
} catch (Exception e) {
future.completeExceptionally(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(old);
}
});
return future;