Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

only closing index-reader if not nil & returning (json-response nil) …

…on feed deletion
  • Loading branch information...
commit 132dda10d7015566772ac7ab08b009082e28137f 1 parent 4689a78
@fmw authored
Showing with 14 additions and 3 deletions.
  1. +5 −2 src/vix/routes.clj
  2. +9 −1 test/vix/test/routes.clj
View
7 src/vix/routes.clj
@@ -43,7 +43,9 @@
(atom (lucene/create-index-reader lucene/directory)))
(defn reset-index-reader! []
- (.close @*index-reader*)
+ (when @*index-reader*
+ (.close @*index-reader*))
+
(compare-and-set! *index-reader*
@*index-reader*
(lucene/create-index-reader lucene/directory)))
@@ -419,7 +421,8 @@
language
feed-name))
(reset-frontpage-cache! language)
- (reset-index-reader!))
+ (reset-index-reader!)
+ (json-response nil))
(json-response nil)))
(POST "/json/:language/:feed/new"
{{language :language feed-name :feed} :params
View
10 test/vix/test/routes.clj
@@ -119,7 +119,15 @@
(do
(reset-index-reader!))
- (is (not (= ir @*index-reader*)))))
+ (is (not (= ir @*index-reader*))))
+
+ (do
+ (compare-and-set! *index-reader* @*index-reader* nil)
+ (is (= @*index-reader* nil))
+ (reset-index-reader!))
+
+ (is (= (class @*index-reader*)
+ org.apache.lucene.index.ReadOnlyDirectoryReader)))
(deftest test-json-response
(is (= (:status (json-response nil)) 404))
Please sign in to comment.
Something went wrong with that request. Please try again.