Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in tools.deps by
closed by

expand-deps dynamically binds
clojure.tools.deps.alpha.util.dir/the-dir before submitting worker
threads. While hard to reproduce, this empirically breaks the
canonicalization of file paths from :local/root dependencies.

Per the Clojure docs for push-thread-bindings:

WARNING: This is a low-level function. Prefer high-level macros like
binding where ever possible. [...] Each call MUST be
accompanied by a matching call to pop-thread-bindings wrapped in a
try-finally!

bound-fn* ensures that dynamically are properly pushed and popped. Using
it from submit-task removes the :local/root canonicalization issues.

 .../clojure/clojure/tools/deps/alpha/util/concurrent.clj    | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/main/clojure/clojure/tools/deps/alpha/util/concurrent.clj b/src/main/clojure/clojure/tools/deps/alpha/util/concurrent.clj
index b1508c10..814e0190 100644
--- a/src/main/clojure/clojure/tools/deps/alpha/util/concurrent.clj
+++ b/src/main/clojure/clojure/tools/deps/alpha/util/concurrent.clj
@@ -29,11 +29,7 @@
 
 (defn submit-task
   ^Future [^ExecutorService executor f]
-  (let [bindings (get-thread-bindings)
-        task #(do
-                (push-thread-bindings bindings)
-                (f))]
-    (.submit executor ^Callable task)))
+  (.submit executor ^Callable (bound-fn* f)))
 
 (defn shutdown-on-error
   [^ExecutorService executor]
closed with the note: Released in Clojure CLI 1.11.1.1347

1 Answer

0 votes
by
...