public static void closeQuietly(AutoCloseable closeable, String name, AtomicReference<Throwable> firstException) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (Throwable t) {
                firstException.compareAndSet(null, t);
                log.error("Failed to close {} with type {}", name, closeable.getClass().getName(), t);
            }
        }
    }
Closes {@code closeable} and if an exception is thrown, it is registered to the firstException parameter.
<b>Be cautious when passing method references as an argument.</b> For example:
<p>
{@code closeQuietly(task::stop, "source task");}
<p>
Although this method gracefully handles null {@link AutoCloseable} objects, attempts to take a method
reference from a null object will result in a {@link NullPointerException}. In the example code above,
it would be the caller's responsibility to ensure that {@code task} was non-null before attempting to
use a method reference from it.
clients/src/main/java/org/apache/kafka/common/utils/Utils.java