Throw exception from user code in SpringFailOnTimeout even if a timeout occurs

Issue: SPR-16717
This commit is contained in:
Igor Suhorukov
2018-04-12 11:37:13 +03:00
committed by Sam Brannen
parent 697d2e326f
commit 3c34a1cb8c
2 changed files with 50 additions and 9 deletions

View File

@@ -88,15 +88,11 @@ public class SpringFailOnTimeout extends Statement {
}
else {
long startTime = System.currentTimeMillis();
try {
this.next.evaluate();
}
finally {
long elapsed = System.currentTimeMillis() - startTime;
if (elapsed > this.timeout) {
throw new TimeoutException(
String.format("Test took %s ms; limit was %s ms.", elapsed, this.timeout));
}
this.next.evaluate();
long elapsed = System.currentTimeMillis() - startTime;
if (elapsed > this.timeout) {
throw new TimeoutException(
String.format("Test took %s ms; limit was %s ms.", elapsed, this.timeout));
}
}
}