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 19, 2014
1 parent 9724c43 commit e94e245
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -10,6 +10,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.core.StopAnalyzer;
import org.apache.lucene.queryparser.classic.ParseException;
Expand Down Expand Up @@ -70,7 +71,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 @@ -81,7 +85,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 @@ -143,7 +147,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 e94e245

Please sign in to comment.