Skip to content

Commit

Permalink
Fixed byte[] support for cmd arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
wallrat committed Apr 2, 2012
1 parent ca81e77 commit 69d9f88
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/labs/redis/core.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)


(def ^:private byte-array-class (Class/forName "[B"))

(defn parse-url [url] (defn parse-url [url]
(let [u (java.net.URI. url) (let [u (java.net.URI. url)
ui (.getUserInfo u) ui (.getUserInfo u)
Expand Down Expand Up @@ -56,14 +58,14 @@
(defn value [^Reply reply] (defn value [^Reply reply]
(.getValue reply)) (.getValue reply))


(let [byte-array-class (Class/forName "[B")]
(defn ->str (defn ->str
"Coerces reply into a String." "Coerces reply into a String."
[reply] [reply]
(condp instance? reply (condp instance? reply
byte-array-class (String. ^bytes reply) byte-array-class (String. ^bytes reply)
BulkReply (String. (.bytes ^BulkReply reply)) BulkReply (String. (.bytes ^BulkReply reply))
java.lang.Object (.toString ^java.lang.Object reply)))) java.lang.Object (.toString ^java.lang.Object reply)))


(defn ->strs [reply] (defn ->strs [reply]
(map ->str (value reply))) (map ->str (value reply)))
Expand All @@ -85,8 +87,7 @@
(keyword? v) (name v) (keyword? v) (name v)
(map? v) (map cmd-arg-convert v) (map? v) (map cmd-arg-convert v)
(vector? v) (map cmd-arg-convert v) (vector? v) (map cmd-arg-convert v)
;; string (instance? byte-array-class v) v
;; byte[]
:default (.toString ^Object v))) :default (.toString ^Object v)))




Expand Down

0 comments on commit 69d9f88

Please sign in to comment.