Skip to content

Commit 1657619

Browse files
authored
Merge pull request #575 from ahr-huber/fix/572
fix #572: TestNG view may miss results
2 parents ceb1dda + 6181082 commit 1657619

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

testng-eclipse-plugin/src/main/org/testng/eclipse/ui/TestRunnerViewPart.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.HashSet;
99
import java.util.List;
1010
import java.util.Set;
11+
import java.util.concurrent.BlockingQueue;
12+
import java.util.concurrent.LinkedBlockingDeque;
1113

1214
import org.eclipse.core.commands.AbstractHandler;
1315
import org.eclipse.core.commands.ExecutionEvent;
@@ -209,6 +211,30 @@ public class TestRunnerViewPart extends ViewPart
209211
// MAX_TEXT_SIZE_THRESHOLD.
210212
private static final int MAX_RESULTS_THRESHOLD = 1000;
211213
private static final int MAX_TEXT_SIZE_THRESHOLD = 3;
214+
215+
private static final BlockingQueue<Runnable> SYNC_RUNNABLE_QUEUE = new LinkedBlockingDeque<>();
216+
217+
static {
218+
Thread t = new Thread() {
219+
@Override
220+
public void run() {
221+
while (true) {
222+
try {
223+
Runnable runnable = SYNC_RUNNABLE_QUEUE.take();
224+
runnable.run();
225+
} catch (InterruptedException ex) {
226+
TestNGPlugin.log(ex);
227+
break;
228+
} catch (RuntimeException ex) {
229+
TestNGPlugin.log(ex);
230+
}
231+
}
232+
}
233+
};
234+
t.setName("testng-sync-runnable-executor"); //$NON-NLS-1$
235+
t.setDaemon(true);
236+
t.start();
237+
}
212238

213239
/** Infos for the current suite run. */
214240
private SuiteRunInfo currentSuiteRunInfo;
@@ -584,9 +610,11 @@ public synchronized void dispose() {
584610
}
585611

586612
private void postSyncRunnable(Runnable r) {
587-
if(!isDisposed()) {
588-
getDisplay().syncExec(r);
589-
}
613+
SYNC_RUNNABLE_QUEUE.add(() -> {
614+
if(!isDisposed()) {
615+
getDisplay().syncExec(r);
616+
}
617+
});
590618
}
591619

592620
private void postAsyncRunnable(Runnable r) {

0 commit comments

Comments
 (0)