我认为这是clojure/tools.logging
. 我有以下db.clj
文件。它做什么并不重要。重要的是,为了安全起见,我禁用了*read-eval*
. 我调用db/start
没有问题。但是,如果我取消注释#_(log/info "Failed to bootstrap")
表单,则会引发EvalReader not allowed
错误。log/info
我已经为通话尝试了各种组合。如果它在try
街区之外,那很好。在try
块内的任何地方,无论是在正文中catch
,还是在 中finally
,都会引发此异常。但是,当我在其他地方环绕时try
,log/info
没关系。
是什么赋予了?
(ns extenium.db
(:require [clojure.tools.logging :as log]
[clojure.java.io :as io])
(:import com.thinkaurelius.titan.core.TitanGraph
com.thinkaurelius.titan.core.TitanFactory))
(def ^:private
sentinel- (Object.))
(def ^:private
db- (atom nil))
...
(defn start [^String path]
(locking sentinel-
(log/info "Starting database at path" path)
(let [exists (.exists (io/file path))
^TitanGraph db_ (TitanFactory/open path)]
(if exists
(log/info "Path" path "exists")
(log/info "Path" path "does not exist"))
(log/info "Starting database engine")
(swap! db- (constantly db_))
(log/info "Started database engine")
(if (not exists)
(try
(bootstrap-)
(catch Throwable t
#_(log/info "Failed to bootstrap")
(stop)
(.delete (io/file path))
(throw t)))))
(log/info "Started database")
true))
编辑:根据@alex-taggart 修剪代码。未显示引导程序实现。我最初包含所有内容,因为这似乎是一个特定于上下文的错误,我觉得提供尽可能多的上下文更安全。
编辑:每个@chouser,添加了我如何禁用*read-eval*
. 这是由 生成的模板lein new app
。
(defn -main
"The main entry point into Extenium."
[& args]
;; Prevent arbitrary eval injection
(alter-var-root #'*read-eval* (constantly false))
;; Initialize system settings from the command line and configuration file
(init!- args)
;; Start the service
(start!-))