You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "javanna (via GitHub)" <gi...@apache.org> on 2023/09/08 11:12:10 UTC

[GitHub] [lucene] javanna commented on a diff in pull request #12544: Close index readers in tests

javanna commented on code in PR #12544:
URL: https://github.com/apache/lucene/pull/12544#discussion_r1319723656


##########
lucene/core/src/test/org/apache/lucene/search/TestSort.java:
##########
@@ -849,11 +849,10 @@ public void testMultiSort() throws IOException {
   }
 
   public void testRewrite() throws IOException {
-    try (Directory dir = newDirectory()) {
-      RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
-      IndexSearcher searcher = newSearcher(writer.getReader());
-      writer.close();
-
+    try (Directory dir = newDirectory();
+        RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
+        DirectoryReader reader = writer.getReader()) {
+      IndexSearcher searcher = newSearcher(reader);

Review Comment:
   I am not too sure, I caught this by creating an executor at all times. Then all tests that use newSearcher and have a cache reader helper need their reader closed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org