diff --git a/src/beanstalk_clj/core.clj b/src/beanstalk_clj/core.clj index 7c02115..babc70c 100644 --- a/src/beanstalk_clj/core.clj +++ b/src/beanstalk_clj/core.clj @@ -154,8 +154,10 @@ of all of the operations within the dynamic scope of body of code." [beanstalkd & body] `(binding [*beanstalkd* ~beanstalkd] - ~@body - (.close *beanstalkd*))) + (let [rs# (do ~@body)] + (.close *beanstalkd*) + rs#))) + (defn inject-beanstalkd [multifn] diff --git a/test/beanstalk_clj/core_test.clj b/test/beanstalk_clj/core_test.clj index e26c05b..b5d6157 100644 --- a/test/beanstalk_clj/core_test.clj +++ b/test/beanstalk_clj/core_test.clj @@ -295,3 +295,11 @@ (is (= "ready" (:state (stats-job job)))) (reserve) (delete jid))))) + +(deftest with-statement-return-value + (testing "return" + (is (number? (with-beanstalkd (beanstalkd-factory) + (let [jid (put "return") + job (reserve)] + (delete jid) + jid))))))