sunng87 / diehard

Clojure resilience library for flexible retry, circuit breaker and rate limiter
Eclipse Public License 2.0
330 stars 27 forks source link

Fix gensym for ignored arguments in reify #46

Closed GaspardP closed 3 years ago

GaspardP commented 3 years ago

Small change that allows the use of Cider's debug capabilities on with-retry, with-circuit-breaker and with-timeout blocks. With the current implementation it fails with a java.lang.RuntimeException: No such var: diehard.core/_.

The problem can be seen when using macroexpand

(let* [opts__15793__auto__ {:timeout-ms 10}
       policy__15794__auto__ (diehard.timeout/timeout-policy-from-config-map opts__15793__auto__)
       async?__15795__auto__ (:async? opts__15793__auto__)
       policies__15796__auto__ (clojure.core/vector policy__15794__auto__)
       failsafe__15797__auto__ (net.jodah.failsafe.Failsafe/with policies__15796__auto__)]
  (.get failsafe__15797__auto__
        (clojure.core/reify
          net.jodah.failsafe.function.CheckedSupplier
          (clojure.core/get [diehard.core/_] ; <= Should be something like `___15826__auto__` instead
            (throw (clojure.core/ex-info "" {}))))))

Can be tested in Cider by evaluating the following snippet

(with-timeout {:timeout-ms 10}
  #dbg (throw (ex-info "error" {})))
sunng87 commented 3 years ago

Good catch! Thanks!

GaspardP commented 3 years ago

Thank you for the quick review and for creating diehard.