You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2014/09/11 20:32:22 UTC
svn commit: r1624357 -
/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java
Author: schor
Date: Thu Sep 11 18:32:22 2014
New Revision: 1624357
URL: http://svn.apache.org/r1624357
Log:
[UIMA-3992] increase reliability of test
Modified:
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java?rev=1624357&r1=1624356&r2=1624357&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/impl/JCasHashMapTest.java Thu Sep 11 18:32:22 2014
@@ -247,19 +247,28 @@ public class JCasHashMapTest extends Tes
assertEquals(numberOfThreads - 1, numberWaiting);
m.put(fs);
found[threadFinished] = fs;
-
- // Attempt to insure we let the threads under test run in preference to this one
- Thread.sleep(20); // imprecise. Intent is to allow other thread that was waiting, to run
- // before this thread resumes. Depends on thread priorities, but
- // multiple threads could be running at the same time.
-
- numberWaiting = 0;
- for (int i = 0; i < numberOfThreads; i++) {
- if (threads[i].isAlive()) {
- numberWaiting ++;
+
+ // loop a few times to give enough time for the other threads to finish.
+ long startOfWait = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startOfWait < 30000) { // wait up to 30 seconds in case of machine stall
+
+ // Attempt to insure we let the threads under test run in preference to this one
+ Thread.sleep(20); // imprecise. Intent is to allow other thread that was waiting, to run
+ // before this thread resumes. Depends on thread priorities, but
+ // multiple threads could be running at the same time.
+
+ numberWaiting = 0;
+ for (int i = 0; i < numberOfThreads; i++) {
+ if (threads[i].isAlive()) {
+ numberWaiting ++;
+ }
+ }
+ if (numberWaiting == 0) {
+ break;
}
}
- assertEquals(0, numberWaiting);
+
+ assertEquals(0, numberWaiting); // if not 0 by now, something is likely wrong, or machine stalled more than 30 seconds
// System.out.format("JCasHashMapTest collide, found = %s%n", intList(found));
for (FeatureStructureImpl f : found) {
if (f != fs) {