code: public static <T> CloseableIterable<T> fromIterable(Iterable<T> iterable) {
          requireNonNull(iterable);
          if (iterable instanceof CloseableIterable) return (CloseableIterable<T>) iterable;
  
          return new FluentCloseableIterable<T>() {
              @Override
              protected void doClose() {
                  if (iterable instanceof AutoCloseable) {
                      try {
                          ((AutoCloseable) iterable).close();
                      } catch (RuntimeException re) {
                          throw re;
                      } catch (Exception e) {
                          throw new IllegalStateException(e);
                      }
                  }
              }
  
              @Override
              protected Iterator<T> retrieveIterator() {
                  return iterable.iterator();
              }
          };
      }
docs: Creates a {@link CloseableIterable} from a standard {@link Iterable}. If {@code iterable} is already
  a {@link CloseableIterable} it will simply be returned as is.