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 2013/05/22 22:11:12 UTC
svn commit: r1485391 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/
lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
Author: rmuir
Date: Wed May 22 20:11:12 2013
New Revision: 1485391
URL: http://svn.apache.org/r1485391
Log:
add a variant of testThreadInterruptDeadlock that uses 2 threads
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/TestIndexWriter.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1485391&r1=1485390&r2=1485391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Wed May 22 20:11:12 2013
@@ -1194,6 +1194,46 @@ public class TestIndexWriter extends Luc
t.join();
assertFalse(t.failed);
}
+
+ /** testThreadInterruptDeadlock but with 2 indexer threads */
+ public void testTwoThreadsInterruptDeadlock() throws Exception {
+ IndexerThreadInterrupt t1 = new IndexerThreadInterrupt();
+ t1.setDaemon(true);
+ t1.start();
+
+ IndexerThreadInterrupt t2 = new IndexerThreadInterrupt();
+ t2.setDaemon(true);
+ t2.start();
+
+ // Force class loader to load ThreadInterruptedException
+ // up front... else we can see a false failure if 2nd
+ // interrupt arrives while class loader is trying to
+ // init this class (in servicing a first interrupt):
+ assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException);
+
+ // issue 300 interrupts to child thread
+ final int numInterrupts = atLeast(300);
+ int i = 0;
+ while(i < numInterrupts) {
+ // TODO: would be nice to also sometimes interrupt the
+ // CMS merge threads too ...
+ Thread.sleep(10);
+ IndexerThreadInterrupt t = random().nextBoolean() ? t1 : t2;
+ if (t.allowInterrupt) {
+ i++;
+ t.interrupt();
+ }
+ if (!t1.isAlive() && !t2.isAlive()) {
+ break;
+ }
+ }
+ t1.finish = true;
+ t2.finish = true;
+ t1.join();
+ t2.join();
+ assertFalse(t1.failed);
+ assertFalse(t2.failed);
+ }
public void testIndexStoreCombos() throws Exception {