public static void swallow(final Logger log, final Level level, final String what, final SwallowAction code,
                               final AtomicReference<Throwable> firstException) {
        if (code != null) {
            try {
                code.run();
            } catch (Throwable t) {
                switch (level) {
                    case INFO:
                        log.info(what, t);
                        break;
                    case DEBUG:
                        log.debug(what, t);
                        break;
                    case ERROR:
                        log.error(what, t);
                        break;
                    case TRACE:
                        log.trace(what, t);
                        break;
                    case WARN:
                    default:
                        log.warn(what, t);
                }
                if (firstException != null)
                    firstException.compareAndSet(null, t);
            }
        }
    }
Run the supplied code. If an exception is thrown, it is swallowed and registered to the firstException parameter.
clients/src/main/java/org/apache/kafka/common/utils/Utils.java