You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/09/30 15:25:03 UTC
svn commit: r1392023 -
/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
Author: mikemccand
Date: Sun Sep 30 13:25:03 2012
New Revision: 1392023
URL: http://svn.apache.org/viewvc?rev=1392023&view=rev
Log:
LUCENE-4451: turn threads back on
Modified:
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java?rev=1392023&r1=1392022&r2=1392023&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java Sun Sep 30 13:25:03 2012
@@ -802,25 +802,45 @@ public abstract class BasePostingsFormat
}
}
+ private static class TestThread extends Thread {
+ private Fields fieldsSource;
+ private EnumSet<Option> options;
+ private IndexOptions maxIndexOptions;
+ private boolean alwaysTestMax;
+ private BasePostingsFormatTestCase testCase;
+
+ public TestThread(BasePostingsFormatTestCase testCase, Fields fieldsSource, EnumSet<Option> options, IndexOptions maxIndexOptions, boolean alwaysTestMax) {
+ this.fieldsSource = fieldsSource;
+ this.options = options;
+ this.maxIndexOptions = maxIndexOptions;
+ this.alwaysTestMax = alwaysTestMax;
+ this.testCase = testCase;
+ }
+
+ @Override
+ public void run() {
+ try {
+ try {
+ testCase.testTermsOneThread(fieldsSource, options, maxIndexOptions, alwaysTestMax);
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ } finally {
+ fieldsSource = null;
+ testCase = null;
+ }
+ }
+ }
+
private void testTerms(final Fields fieldsSource, final EnumSet<Option> options,
final IndexOptions maxIndexOptions,
final boolean alwaysTestMax) throws Exception {
- // TODO: turn threads back on!
- if (false && options.contains(Option.THREADS)) {
+ if (options.contains(Option.THREADS)) {
int numThreads = _TestUtil.nextInt(random(), 2, 5);
Thread[] threads = new Thread[numThreads];
for(int threadUpto=0;threadUpto<numThreads;threadUpto++) {
- threads[threadUpto] = new Thread() {
- @Override
- public void run() {
- try {
- testTermsOneThread(fieldsSource, options, maxIndexOptions, alwaysTestMax);
- } catch (Throwable t) {
- throw new RuntimeException(t);
- }
- }
- };
+ threads[threadUpto] = new TestThread(this, fieldsSource, options, maxIndexOptions, alwaysTestMax);
threads[threadUpto].start();
}
for(int threadUpto=0;threadUpto<numThreads;threadUpto++) {
@@ -1009,6 +1029,8 @@ public abstract class BasePostingsFormat
testTerms(fieldsProducer, EnumSet.allOf(Option.class), IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, false);
fieldsProducer.close();
+ fieldsProducer = null;
+
dir.close();
_TestUtil.rmDir(path);
}