diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/ContextStorageCloser.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/ContextStorageCloser.java index 1423692dc6..5ddc379d3d 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/ContextStorageCloser.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/ContextStorageCloser.java @@ -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 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);