Skip to content

Commit

Permalink
Fix: NPE reading optional results from cache
Browse files Browse the repository at this point in the history
We were seeing null pointer exceptions reading results from the disk
that used OPTIONAL in the query.

Grafter has been updated in grafter/#130 to handle nulls safely, which
prevents the exception, but does put nils in our result sets. Meaning
that the same query can have different results from the db (no nils)
or the disk (w/ nils).

I've added a test on the graph loading time to ensure everything
returns as it should. That's an OPTIONAL using query so a great
example.

This resolves #264
  • Loading branch information
Dan Midwood committed Jun 8, 2018
1 parent aa3b3b4 commit 14a5271
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
[com.sun.mail/javax.mail "1.6.0"]
;;[com.taoensso/tower "2.0.2"]

[grafter "0.11.0-drafter-rdf4j-261-SNAPSHOT"]
[grafter "0.11.0.2-drafter-rdf4j-SNAPSHOT"]

[grafter/url "0.2.5"]
;[grafter/vocabularies "0.1.3"]
Expand Down
23 changes: 21 additions & 2 deletions test/drafter/stasher_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,31 @@


(deftest-system fetch-modified-state-test
;; Here we're just testing the underlying modified time queries, so we do
;; so on a standard RDF4j repo, not a stasher/caching one.
[{repo :drafter.stasher/repo} "drafter/stasher-test/drafter-state-1.edn"]
(t/is (some? repo) "No repo!")
(with-open [conn (.getConnection repo)]

(t/testing "Fetching draftset modified times"
(t/is (= ds-1-most-recently-modified
(sut/fetch-modified-state conn {:named-graphs ds-1 :default-graphs ds-1})))

(t/is (= ds-2-most-recently-modified
(sut/fetch-modified-state conn {:named-graphs ds-2 :default-graphs ds-2}))))

(t/testing "Fetching live graph modified times"
(t/is (= liveset-most-recently-modified
(sut/fetch-modified-state conn {:named-graphs [live-graph-1 live-graph-only] :default-graphs [live-graph-1 live-graph-only]}))))

(t/testing "Fetching draftsets with union-with-live set"
;; Union with live is at this low level equivalent to merging the
;; set of live graphs in to :named-graphs and :default-graphs.
(let [ds-1-union-with-live (conj ds-1 live-graph-1 live-graph-only)
dataset {:named-graphs ds-1-union-with-live :default-graphs ds-1-union-with-live}]
(t/is (= (merge liveset-most-recently-modified
ds-1-most-recently-modified)
(sut/fetch-modified-state conn dataset))))))
(with-open [conn (.getConnection repo)]

(t/testing "Fetching draftset modified times"
(t/is (= ds-1-most-recently-modified
(sut/fetch-modified-state conn {:named-graphs ds-1 :default-graphs ds-1})))
Expand Down

0 comments on commit 14a5271

Please sign in to comment.