You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/09/17 16:06:40 UTC
svn commit: r1386619 -
/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
Author: rmuir
Date: Mon Sep 17 14:06:39 2012
New Revision: 1386619
URL: http://svn.apache.org/viewvc?rev=1386619&view=rev
Log:
try to ensure we close the directory even if we throw an assumption
Modified:
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java?rev=1386619&r1=1386618&r2=1386619&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java Mon Sep 17 14:06:39 2012
@@ -454,18 +454,23 @@ public class TestIndexWriterWithThreads
thread1.join();
thread2.join();
- assumeFalse("aborting test: timeout obtaining lock", thread1.failure instanceof LockObtainFailedException);
- assumeFalse("aborting test: timeout obtaining lock", thread2.failure instanceof LockObtainFailedException);
-
- assertFalse("Failed due to: " + thread1.failure, thread1.failed);
- assertFalse("Failed due to: " + thread2.failure, thread2.failed);
- // now verify that we have two documents in the index
- IndexReader reader = DirectoryReader.open(dir);
- assertEquals("IndexReader should have one document per thread running", 2,
+ // ensure the directory is closed if we hit the timeout and throw assume
+ // TODO: can we improve this in LuceneTestCase? I dont know what the logic would be...
+ try {
+ assumeFalse("aborting test: timeout obtaining lock", thread1.failure instanceof LockObtainFailedException);
+ assumeFalse("aborting test: timeout obtaining lock", thread2.failure instanceof LockObtainFailedException);
+
+ assertFalse("Failed due to: " + thread1.failure, thread1.failed);
+ assertFalse("Failed due to: " + thread2.failure, thread2.failed);
+ // now verify that we have two documents in the index
+ IndexReader reader = DirectoryReader.open(dir);
+ assertEquals("IndexReader should have one document per thread running", 2,
reader.numDocs());
- reader.close();
- dir.close();
+ reader.close();
+ } finally {
+ dir.close();
+ }
}
static class DelayedIndexAndCloseRunnable extends Thread {