Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make ->str et all handle nil -> nil

  • Loading branch information...
commit b4285112da964ae1923a8f325beb13b14310e516 1 parent 69d9f88
@wallrat authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/labs/redis/core.clj
View
21 src/labs/redis/core.clj
@@ -62,19 +62,22 @@
(defn ->str
"Coerces reply into a String."
[reply]
- (condp instance? reply
- byte-array-class (String. ^bytes reply)
- BulkReply (String. (.bytes ^BulkReply reply))
- java.lang.Object (.toString ^java.lang.Object reply)))
+ (when reply
+ (condp instance? reply
+ byte-array-class (String. ^bytes reply)
+ BulkReply (String. (.bytes ^BulkReply reply))
+ java.lang.Object (.toString ^java.lang.Object reply))))
(defn ->strs [reply]
- (map ->str (value reply)))
+ (when reply
+ (map ->str (value reply))))
(defn ->>str [r]
- (condp instance? r
- MultiBulkReply (map ->>str (value r))
- Reply (->>str (value r))
- java.lang.Object (->str r)))
+ (when r
+ (condp instance? r
+ MultiBulkReply (map ->>str (value r))
+ Reply (->>str (value r))
+ java.lang.Object (->str r))))
;; low level redis protocol fns
Please sign in to comment.
Something went wrong with that request. Please try again.