Fix #1619: fix reflection issue with core.async/timeout (#1620)

This commit is contained in:
Michiel Borkent 2023-09-05 12:53:42 +02:00 committed by GitHub
parent b1d2dc599b
commit ad6cd5989f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -10,6 +10,7 @@ A preview of the next release can be installed from
## Unreleased
- Bump babashka.http-client to v0.4.15
- [#1619](https://github.com/babashka/babashka/issues/1619): Fix reflection issue with `Thread/sleep` in `core.async/timeout`
## 1.3.184 (2023-08-22)

View file

@ -6,6 +6,8 @@
[sci.impl.copy-vars :refer [macrofy]]
[sci.impl.vars :as vars]))
(set! *warn-on-reflection* true)
(def ^java.util.concurrent.Executor executor @#'async/thread-macro-executor)
(def ^java.util.concurrent.Executor virtual-executor
@ -72,7 +74,7 @@
(if virtual-executor
(let [chan (async/chan nil)]
(.execute virtual-executor (fn []
(Thread/sleep ms)
(Thread/sleep (long ms))
(async/close! chan)))
chan)
(async/timeout ms)))

View file

@ -42,3 +42,11 @@
[(async/go
(async/<! (async/timeout 100))
10)])))))")))))
(deftest timeout-test
(is (nil? (edn/read-string (test-utils/bb nil "
(first (async/<!!
(async/go
(async/alts!
[(async/go
(async/<! (async/timeout (int 100))))]))))")))))