public static void closeQuietly(String closeMethod, @Nullable Object... objects) {
    if (objects != null) {
      Arrays
        .stream(objects)
        .filter(Objects::nonNull)
        .forEach(object -> invokeMethodQuietly(object, closeMethod));
    }
  }
Note: This method may throw checked exceptions although it doesn't say so.
spock-core/src/main/java/org/spockframework/runtime/GroovyRuntimeUtil.java