Skip to content

Commit

Permalink
HSEARCH-1722 Fix race condition in OptimizerPerformanceTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fernandes authored and Sanne committed Nov 18, 2014
1 parent 9ad4931 commit 5e9a4ec
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.ParseException;
Expand Down Expand Up @@ -87,7 +88,10 @@ public void testConcurrency() throws Exception {
es.execute( work );
es.execute( reverseWork );
}
while ( work.count < iteration - 1 ) {

es.shutdown();

while ( work.count.get() < iteration - 1 ) {
Thread.sleep( 20 );
}
System.out.println(
Expand All @@ -98,7 +102,7 @@ public void testConcurrency() throws Exception {

protected static class Work implements Runnable {
private final SessionFactory sf;
public volatile int count = 0;
public AtomicInteger count = new AtomicInteger( 0 );

public Work(SessionFactory sf) {
this.sf = sf;
Expand Down Expand Up @@ -160,7 +164,7 @@ public void run() {
s.delete( c );
tx.commit();
s.close();
count++;
count.incrementAndGet();
}
catch (Throwable t) {
t.printStackTrace();
Expand Down

0 comments on commit 5e9a4ec

Please sign in to comment.