class StrictScopeDecorator implements ScopeDecorator, Closeable {

  @Override public void close() {
    // toArray is synchronized while iterators are not
    CallerStackTrace[] leakedCallers = currentCallers.toArray(new CallerStackTrace[0]);
    for (CallerStackTrace caller : leakedCallers) {
      // Sometimes unit test runners truncate the cause of the exception.
      // This flattens the exception as the caller of close() isn't important vs the one that leaked
      AssertionError toThrow = new AssertionError(
        "Thread [" + caller.threadName + "] opened a scope of " + caller.context + " here:");
      toThrow.setStackTrace(caller.getStackTrace());
      throw toThrow;
    }
  }

    StrictScopeDecorator();

}