Print out thread dump on strict context check failure (#4664)
* Print out thread dump on strict context check failure * suppress warning
This commit is contained in:
parent
db0d0c350a
commit
31d87162f3
|
@ -41,7 +41,8 @@ public final class ContextStorageCloser {
|
|||
// retry close when scope leak was reported.
|
||||
await()
|
||||
.ignoreException(AssertionError.class)
|
||||
.atMost(Duration.ofSeconds(15))
|
||||
.atMost(Duration.ofSeconds(10))
|
||||
.pollInterval(Duration.ofSeconds(1))
|
||||
.until(() -> restorer.runWithRestore(storage));
|
||||
}
|
||||
|
||||
|
@ -50,6 +51,7 @@ public final class ContextStorageCloser {
|
|||
private abstract static class ContextRestorer {
|
||||
abstract void restore();
|
||||
|
||||
@SuppressWarnings("SystemOut")
|
||||
boolean runWithRestore(AutoCloseable target) {
|
||||
try {
|
||||
target.close();
|
||||
|
@ -57,6 +59,15 @@ public final class ContextStorageCloser {
|
|||
} catch (Throwable throwable) {
|
||||
restore();
|
||||
if (throwable instanceof AssertionError) {
|
||||
System.err.println();
|
||||
for (Map.Entry<Thread, StackTraceElement[]> threadEntry :
|
||||
Thread.getAllStackTraces().entrySet()) {
|
||||
System.err.println("Thread " + threadEntry.getKey());
|
||||
for (StackTraceElement stackTraceElement : threadEntry.getValue()) {
|
||||
System.err.println("\t" + stackTraceElement);
|
||||
}
|
||||
System.err.println();
|
||||
}
|
||||
throw (AssertionError) throwable;
|
||||
}
|
||||
throw new IllegalStateException(throwable);
|
||||
|
|
Loading…
Reference in New Issue