NO-JIRA Adding Thread Dump to be reported on failing Wait conditions

This commit is contained in:
Clebert Suconic 2020-12-22 13:28:30 -05:00
parent 372220ad3f
commit 4dd51bc1ef
1 changed files with 7 additions and 0 deletions

View File

@ -68,6 +68,7 @@ public class Wait {
boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);
if (!result) {
System.out.println(ThreadDumpUtil.threadDump("thread dump"));
Assert.fail(size + " != " + condition.getCount());
}
}
@ -86,6 +87,7 @@ public class Wait {
boolean result = waitFor(() -> (obj == condition || obj.equals(condition.getObject())), timeout, sleepMillis);
if (!result) {
System.out.println(ThreadDumpUtil.threadDump("thread dump"));
Assert.assertEquals(obj, condition.getObject());
}
}
@ -94,6 +96,7 @@ public class Wait {
boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);
if (!result) {
System.out.println(ThreadDumpUtil.threadDump("thread dump"));
Assert.fail(size + " != " + condition.getCount());
}
}
@ -140,6 +143,7 @@ public class Wait {
boolean result = waitFor(condition, duration, sleep);
if (!result) {
System.out.println(ThreadDumpUtil.threadDump("thread dump"));
Assert.fail(failureMessage);
}
}
@ -163,6 +167,9 @@ public class Wait {
}
conditionSatisified = condition.isSatisfied();
}
if (!conditionSatisified) {
System.out.println(ThreadDumpUtil.threadDump("thread dump"));
}
return conditionSatisified;
} catch (Exception e) {
throw new IllegalStateException(e);