StrictScopeDecorator implements ScopeDecorator, Closeable { @Override public void close() { CallerStackTrace[] leakedCallers = currentCallers.toArray(new CallerStackTrace[0]); for (CallerStackTrace caller : leakedCallers) { AssertionError toThrow = new AssertionError( "Thread [" + caller.threadName + "] opened a scope of " + caller.context + " here:"); toThrow.setStackTrace(caller.getStackTrace()); throw toThrow; } } StrictScopeDecorator(); static StrictScopeDecorator create(); @Override Scope decorateScope(@Nullable TraceContext context, Scope scope); @Override void close();  }
@Test public void decorator_close_afterCorrectUsage() { try (Scope ws = currentTraceContext.newScope(null)) { try (Scope ws2 = currentTraceContext.newScope(context)) { } } decorator.close(); }