NO-JIRA More Strict settings for test thread leaks

I'm investigating thread leakages and previous change on this class here is biting me.
This commit is contained in:
Clebert Suconic 2018-05-03 21:36:40 -04:00
parent 61d2cc5bb0
commit bc09a8011d
1 changed files with 9 additions and 1 deletions

View File

@ -44,6 +44,10 @@ public class ThreadLeakCheckRule extends TestWatcher {
protected boolean testFailed = false;
protected Description testDescription = null;
protected Throwable failure = null;
protected Map<Thread, StackTraceElement[]> previousThreads;
/**
@ -65,7 +69,9 @@ public class ThreadLeakCheckRule extends TestWatcher {
@Override
protected void failed(Throwable e, Description description) {
this.failure = e;
this.testFailed = true;
this.testDescription = description;
}
@Override
@ -86,7 +92,7 @@ public class ThreadLeakCheckRule extends TestWatcher {
boolean failedOnce = false;
// if the test failed.. there's no point on waiting a full minute.. we will report it once and go
long timeout = System.currentTimeMillis() + (testFailed ? 1000 : 60000);
long timeout = System.currentTimeMillis() + (testFailed ? 30000 : 60000);
while (failed && timeout > System.currentTimeMillis()) {
failed = checkThread();
@ -108,6 +114,8 @@ public class ThreadLeakCheckRule extends TestWatcher {
System.out.println("***********************************************************************");
System.out.println(" The test failed and there is a leak");
System.out.println("***********************************************************************");
failure.printStackTrace();
Assert.fail("Test " + testDescription + " Failed with a leak - " + failure.getMessage());
}
} else if (failedOnce) {
System.out.println("******************** Threads cleared after retries ********************");