File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 40
40
41
41
clojure.lang.Indexed
42
42
(nth [_ i]
43
- (let [cursor (.getCursor ral (long i))]
44
- (common/-read-from-cursor cursor)))
43
+ (let [count (.count ral)
44
+ idx (long i)]
45
+ (if (and (>= idx 0 ) (< idx count))
46
+ (common/-read-from-cursor (.getCursor ral idx))
47
+ (throw (IndexOutOfBoundsException. (str " Index: " i " , Size: " count))))))
45
48
46
49
(nth [_ i not-found]
47
50
(let [cursor (.getCursor ral (long i))]
Original file line number Diff line number Diff line change 185
185
cursor (.getCursor rhs hash-code)]
186
186
(some? cursor)))
187
187
188
- (defn ^WriteHashMap set-empty!
188
+ (defn ^WriteHashSet set-empty!
189
189
" Replaces the whs value with an empty set."
190
190
[^WriteHashSet whs]
191
191
(let [empty-set (conversion/v->slot! (.cursor whs) #{})]
Original file line number Diff line number Diff line change 24
24
(swap! cursor1 assoc-in [3 :hidden ] :changed-by-swap! )
25
25
(is (= [1 2 3 {:hidden :changed-by-swap! } 5 ]) (xdb/materialize @cursor1))
26
26
(is (= :changed-by-swap! @cursor3))
27
- (is (= 3 @cursor2))))))
27
+ (is (= 3 @cursor2)))
28
+
29
+ (testing " Correctly handles invalid cursor path"
30
+ (is (thrown? IndexOutOfBoundsException @(xdb/xdb-cursor db [:foo :bar 999 ])))))))
You can’t perform that action at this time.
0 commit comments