Skip to content

Commit 498e5a1

Browse files
committed
FIx nil pointer exception
1 parent 545bef0 commit 498e5a1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/xitdb/hash_set.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(throw (UnsupportedOperationException. "XITDBHashSet is read-only")))
1717

1818
(contains [this k]
19-
(not (nil? (.getCursor rhm (util/db-key (.hashCode k))))))
19+
(not (nil? (.getCursor rhm (util/db-key (if (nil? k) 0 (.hashCode k)))))))
2020

2121
(get [this k]
2222
(when (.contains this k)

test/xitdb/set_test.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,12 @@
8181
(is (= {:sweets #{:regular-candy :chupa-chups, :mochi :tiramisu}}
8282
(tu/materialize @db1))))))
8383

84+
(deftest nil-test
85+
(with-db [db (tu/test-db)]
86+
(reset! db {:sweets #{nil :mochi}})
87+
(testing "Handles nil correctly"
88+
(let [sweets (:sweets @db)]
89+
(is (true? (contains? sweets nil)))))))
90+
8491

8592

0 commit comments

Comments
 (0)