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:07:05 UTC
svn commit: r1386620 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/
lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
Author: rmuir
Date: Mon Sep 17 14:07:05 2012
New Revision: 1386620
URL: http://svn.apache.org/viewvc?rev=1386620&view=rev
Log:
try to ensure we close the directory even if we throw an assumption
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java?rev=1386620&r1=1386619&r2=1386620&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java Mon Sep 17 14:07:05 2012
@@ -456,18 +456,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 {