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.
|
// retry close when scope leak was reported.
|
||||||
await()
|
await()
|
||||||
.ignoreException(AssertionError.class)
|
.ignoreException(AssertionError.class)
|
||||||
.atMost(Duration.ofSeconds(15))
|
.atMost(Duration.ofSeconds(10))
|
||||||
|
.pollInterval(Duration.ofSeconds(1))
|
||||||
.until(() -> restorer.runWithRestore(storage));
|
.until(() -> restorer.runWithRestore(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ public final class ContextStorageCloser {
|
||||||
private abstract static class ContextRestorer {
|
private abstract static class ContextRestorer {
|
||||||
abstract void restore();
|
abstract void restore();
|
||||||
|
|
||||||
|
@SuppressWarnings("SystemOut")
|
||||||
boolean runWithRestore(AutoCloseable target) {
|
boolean runWithRestore(AutoCloseable target) {
|
||||||
try {
|
try {
|
||||||
target.close();
|
target.close();
|
||||||
|
@ -57,6 +59,15 @@ public final class ContextStorageCloser {
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
restore();
|
restore();
|
||||||
if (throwable instanceof AssertionError) {
|
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 (AssertionError) throwable;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException(throwable);
|
throw new IllegalStateException(throwable);
|
||||||
|
|
Loading…
Reference in New Issue