Clojure def给出UnsupportedOperationException

时间:2011-01-18 17:39:23

标签: clojure

我正在尝试从clojure客户端ping fleetdb。当我ping服务器时,我收到响应“pong”,但当我尝试使用def将其保存到变量时,我得到“UnsupportedOperationException applyTo”。

(use 'fleetdb.client)

(def client (connect {:host "127.0.0.1", :port 3400}))

(client ["ping"]) ; get back "pong" as response

(type  (client ["ping"]))   ;java.lang.String

(print (client ["ping"]))   ; get back "pong" as response

(def isalive (client ["ping"])) 

; UnsupportedOperationException applyTo  fleetdb.client.proxy$java.lang.Object$IFn

; $ILookup$Closeable$9aed515e.applyTo (:-1)

尝试使用clojure 1.2和1.3.0-alpha4

有什么问题?

1 个答案:

答案 0 :(得分:1)

似乎客户端代理没有定义作为IFn接口一部分的 applyTo 方法:

https://github.com/mmcgrana/fleetdb-client/blob/master/src/fleetdb/client.clj#L54

这将有效:

user> (def x (.invoke client ["ping"]))
#'user/x

需要查看,为什么使用 applyTo 代替调用