Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method schedule on class java.util.concurrent.Executors$DelegatedScheduledExecutorService not allowed! #1264

Closed
dominicfreeston opened this issue May 12, 2022 · 1 comment

Comments

@dominicfreeston
Copy link

dominicfreeston commented May 12, 2022

version

0.8.2

platform

macOS 11.6

problem

Getting a Method schedule on class java.util.concurrent.Executors$DelegatedScheduledExecutorService not allowed! message when trying to call schedule on a scheduler.

repro

(import '[java.util.concurrent Executors TimeUnit])
(defn debounce [f delay-ms]
  (let [scheduler (Executors/newSingleThreadScheduledExecutor)
        task (atom nil)]
    (fn []
      (let [[old _] (reset-vals! task (.schedule scheduler f delay-ms TimeUnit/MILLISECONDS))]
        (when old
          (.cancel old true))))))
(def test-fn (debounce #(println "Hi!") 1000))
(test-fn)
(test-fn)
(test-fn)

expected behavior

Prints out "Hi!" once after about a second.

@dominicfreeston dominicfreeston changed the title Method schedule on class java.util.concurrent.Executors$DelegatedScheduledExecutorService not allowed! Method schedule on class java.util.concurrent.Executors$DelegatedScheduledExecutorService not allowed! May 12, 2022
@borkdude
Copy link
Collaborator

Thanks. In the meantime, take a look at https://github.com/overtone/at-at which does work with babashka.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants