private void logThreadDumpOfCurrentJvm() {
    if (configuration.printThreadDumpsOnInterruptAttempts) {
      StringBuilder sb = new StringBuilder();
      try {
        threadDumpCollector.appendThreadDumpOfCurrentJvm(sb);
        System.err.println(removeThisThread(sb.toString()));
      } catch (Throwable e) {
        rethrowIfUnrecoverable(e);

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        e.printStackTrace(new PrintStream(stream));

        String result = "Error in attempt to fetch thread dumps: " + stream;
        if (sb.length() > 0) {
          result += "\n\nPartial thread dumps:\n" + sb;
        }
        System.err.println(result);
      }
    }
  }
Times out a method invocation if it takes too long. The method invocation
will occur on the regular test framework thread. This can be important
for integration tests with thread-local state.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/extension/builtin/TimeoutInterceptor.java